0

I was reading through this profile configuration.

<profiles>
   <profile>
     <id>test</id>
     <build>
       <plugins>
         <plugin>
           <artifactId>maven-antrun-plugin</artifactId>
           <executions>
             <execution>
               <phase>test</phase>
               <goals>
                 <goal>run</goal>
               </goals>
               <configuration>
                 <tasks>
                   <delete file="${project.build.outputDirectory}/environment.properties"/>
                   <copy file="src/main/resources/environment.test.properties"
                         tofile="${project.build.outputDirectory}/environment.properties"/>
                 </tasks>
               </configuration>
             </execution>
           </executions>
         </plugin>
         <plugin>
           <artifactId>maven-surefire-plugin</artifactId>
           <configuration>
             <skip>true</skip>
           </configuration>
         </plugin>
         <plugin>
           <artifactId>maven-jar-plugin</artifactId>
           <executions>
             <execution>
               <phase>package</phase>
               <goals>
                 <goal>jar</goal>
               </goals>
               <configuration>
                 <classifier>test</classifier>
               </configuration>
             </execution>
           </executions>
         </plugin>
       </plugins>
     </build>
   </profile>

   .. Other profiles go here ..

 </profiles>

why maven-surefire-plugin is configured skip here. I don't see any phase it is bound to?

And according to the antrun configuartion, the artifact would end up with environment.test.properties (renamed as environment.properties). But that is not expected correct?

brain storm
  • 30,124
  • 69
  • 225
  • 393
  • Whoever wrote this pom didn't understand the concept of production and test code and the usage of `src/main/resources` vs. `src/test/resources` which seemed to be exactly the use case here. Or on the other hand someone tries to create different jars for different environments which shows also that this is the wrong way. Just run `mvn clean package` and get everything you need (may be several jar's for different environments). The surefure plugin is configured just simply to be skipped so no tests will run according to a change in configuration which could fail tests. – khmarbaise May 15 '15 at 21:32
  • but why surefire plugin needs to be skipped, since when package phase has come, test has already finished in the build lifecycle. not clear to me what is happening? – brain storm May 15 '15 at 21:39
  • That's the weird thing in this profile cause it copies the properties into the correct location (which is done in the test phase which does not make sense either) and will let package the jar file with a classifier to identify it's for a different environment but with these properties the tests will probably fail and that's the reason to skip surefire plugin. – khmarbaise May 15 '15 at 22:09

0 Answers0