File tree Expand file tree Collapse file tree 6 files changed +121
-8
lines changed Expand file tree Collapse file tree 6 files changed +121
-8
lines changed Original file line number Diff line number Diff line change 1+ <?xml  version =" 1.0"  encoding =" UTF-8" 
2+ <project  xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" 
3+   <modelVersion >4.0.0</modelVersion >
4+   <groupId >com.github.ekryd.sortpom.its</groupId >
5+   <artifactId >quiet-sorting</artifactId >
6+   <version >0.0.1-SNAPSHOT</version >
7+   <packaging >pom</packaging >
8+   <name >SortPom Plugin :: ITs :: Quiet Sorting</name >
9+   <description >Sorting, but no messages</description >
10+   <url >no-url</url >
11+   <properties >
12+     <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
13+   </properties >
14+   <dependencies >
15+     <dependency >
16+       <groupId >org.apache.maven.plugin-tools</groupId >
17+       <artifactId >maven-plugin-annotations</artifactId >
18+       <version >RELEASE</version >
19+       <scope >provided</scope >
20+     </dependency >
21+   </dependencies >
22+   <build >
23+     <plugins >
24+       <plugin >
25+         <groupId >com.github.ekryd.sortpom</groupId >
26+         <artifactId >sortpom-maven-plugin</artifactId >
27+         <version >@pom.version@</version >
28+         <executions >
29+           <execution >
30+             <goals >
31+               <goal >sort</goal >
32+             </goals >
33+             <configuration >
34+               <quiet >true</quiet >
35+             </configuration >
36+           </execution >
37+         </executions >
38+       </plugin >
39+     </plugins >
40+   </build >
41+ </project >
Original file line number Diff line number Diff line change 1+ invoker.goals =-e clean verify
Original file line number Diff line number Diff line change 1+ <?xml  version =" 1.0"  encoding =" UTF-8" 
2+ <project  xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" 
3+   <modelVersion >4.0.0</modelVersion >
4+   <groupId >com.github.ekryd.sortpom.its</groupId >
5+   <artifactId >quiet-sorting</artifactId >
6+   <version >0.0.1-SNAPSHOT</version >
7+   <packaging >pom</packaging >
8+   <name >SortPom Plugin :: ITs :: Quiet Sorting</name >
9+   <description >Sorting, but no messages</description >
10+   <url >no-url</url >
11+   <properties >
12+     <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
13+   </properties >
14+ <dependencies >
15+ <dependency >
16+ <groupId >org.apache.maven.plugin-tools</groupId >
17+ <artifactId >maven-plugin-annotations</artifactId >
18+ <version >RELEASE</version >
19+ <scope >provided</scope >
20+ </dependency >
21+ </dependencies >
22+   <build >
23+     <plugins >
24+       <plugin >
25+         <groupId >com.github.ekryd.sortpom</groupId >
26+         <artifactId >sortpom-maven-plugin</artifactId >
27+         <version >@pom.version@</version >
28+         <executions >
29+           <execution >
30+             <goals >
31+               <goal >sort</goal >
32+             </goals >
33+             <configuration >
34+               <quiet >true</quiet >
35+             </configuration >
36+           </execution >
37+         </executions >
38+       </plugin >
39+     </plugins >
40+   </build >
41+ </project >
Original file line number Diff line number Diff line change 1+ log =  new  File (basedir, ' build.log' 
2+ sorted =  new  File (basedir, ' pom.xml' 
3+ expected =  new  File (basedir, ' expected/pom.xml' 
4+ backup =  new  File (basedir, ' pom.xml.bak' 
5+ 
6+ assert  log. exists()
7+ assert  ! log. text. contains(' Sorting file ' +  sorted. absolutePath)
8+ assert  ! log. text. contains(' Saved backup of ' +  sorted. absolutePath +  '  to ' +  backup. absolutePath)
9+ assert  ! log. text. contains(' Saved sorted pom file to ' +  sorted. absolutePath)
10+ assert  backup. exists()
11+ assert  expected. text. replaceAll(' @pom.version@' . tokenize(' \n ' . equals(sorted. text. replaceAll(' \r ' ' ' . tokenize(' \n ' 
12+ 
13+ return  true 
Original file line number Diff line number Diff line change 11package  sortpom ;
22
3+ import  java .io .File ;
34import  org .apache .maven .plugin .AbstractMojo ;
45import  org .apache .maven .plugin .MojoFailureException ;
56import  org .apache .maven .plugins .annotations .Parameter ;
67import  sortpom .logger .MavenLogger ;
78import  sortpom .logger .SortPomLogger ;
89
9- import  java .io .File ;
10- 
1110/** Common parent for both SortMojo and VerifyMojo */ 
1211abstract  class  AbstractParentMojo  extends  AbstractMojo  {
1312
@@ -126,14 +125,14 @@ abstract class AbstractParentMojo extends AbstractMojo {
126125  @ Parameter (property  = "sort.sortExecutions" , defaultValue  = "false" )
127126  boolean  sortExecutions ;
128127
129-   /** Set this to 'true' to bypass sortpom plugin */ 
130-   @ Parameter (property  = "sort.skip" , defaultValue  = "false" )
131-   private  boolean  skip ;
132- 
133128  /** Whether to keep the file timestamps of old POM file when creating new POM file. */ 
134129  @ Parameter (property  = "sort.keepTimestamp" , defaultValue  = "false" )
135130  boolean  keepTimestamp ;
136131
132+   /** Set this to 'true' to bypass sortpom plugin */ 
133+   @ Parameter (property  = "sort.skip" , defaultValue  = "false" )
134+   private  boolean  skip ;
135+ 
137136  /** Set this to 'true' to disable plugin info output */ 
138137  @ Parameter (property  = "sort.quiet" , defaultValue  = "false" )
139138  private  boolean  quiet ;
Original file line number Diff line number Diff line change @@ -37,11 +37,29 @@ void infoShouldOutputInfoLevel() {
3737    verifyNoMoreInteractions (logMock );
3838  }
3939
40+   @ Test 
41+   void  quietLoggingShouldOutputInfoOnDebugLevel () {
42+     var  quietMavenLogger  = new  MavenLogger (logMock , true );
43+     quietMavenLogger .info ("Gurka" );
44+ 
45+     verify (logMock ).debug ("Gurka" );
46+     verifyNoMoreInteractions (logMock );
47+   }
48+ 
49+   @ Test 
50+   void  quietLoggingShouldStillOutputErrorLevel () {
51+     var  quietMavenLogger  = new  MavenLogger (logMock , true );
52+     quietMavenLogger .error ("Error!" );
53+ 
54+     verify (logMock ).error ("Error!" );
55+     verifyNoMoreInteractions (logMock );
56+   }
57+ 
4058  @ Test 
4159  void  errorShouldOutputErrorLevel () {
42-     mavenLogger .error ("Gurka " );
60+     mavenLogger .error ("Error! " );
4361
44-     verify (logMock ).error ("Gurka " );
62+     verify (logMock ).error ("Error! " );
4563    verifyNoMoreInteractions (logMock );
4664  }
4765}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments