Maven exec plugin: Running Java programs during maven builds
Sometimes it is easier to run or execute a Java program instead of writing a maven plugin.
In the following example, the class com.magicmonster.example.Main
will be run. Note the phase has to come after the
‘compile’ phase if your main class is from your current project. Alternatively, if the main class is included via a
maven dependency, any phase will work.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<id>custom-exec-1</id>
<phase>prepare-package</phase>
<configuration>
<mainClass>com.magicmonster.example.Main</mainClass>
<arguments>
<argument>hello</argument>
<argument>world</argument>
</arguments>
<systemProperties>
<systemProperty>
<key>com.magicmonster.example.sysproperty1</key>
<value>value1</value>
</systemProperty>
</systemProperties>
</configuration>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
</plugin>