I need to execute several java classes during maven build phase, but plugin executes only class from first execution
Pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>first</id>
<goals>
<goal>java</goal>
</goals>
<phase>test-compile</phase>
<configuration>
<mainClass>com.myPackage.AssignTest</mainClass>
</configuration>
</execution>
<execution>
<id>second</id>
<goals>
<goal>java</goal>
</goals>
<phase>test-compile</phase>
<configuration>
<mainClass>com.myPackage.CompareTest</mainClass>
</configuration>
</execution>
</executions>
</plugin>
Does somebody know where is an error?
In case someone will want an answer to this. From experimenting I've found that the
java
goal does not support multiple executions, but theexec
goal does. So just transform java into execBelow is an example of how to run the above code with the
exec
goal.If classes you want to run reside in your actual code, you will probably need to bind the exec goal to a phase after
compile
. Else they will simply be picked up from the project dependencies.