Maven2 exec plugin: Runing Java programs during maven builds
Exec Maven Plugin
Sometimes it is easier to just run or execute a Java program instead of trying to figure out 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 I think any phase will work.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<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>
</plugin>
Published: Saturday, 25 June 2011

