Running a task post maven install
maven, maven-2
Solution
If you want to run this command as part of the normal build lifecycle, there is no other way than binding the `exec` goal on the `install` phase:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>my-exec</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<inherited>false</inherited>
</execution>
</executions>
<configuration>
<executable>COMMAND</executable>
</configuration>
</plugin>
</plugins>
</build>
I did a simple test using the configuration above (using `ls` as "COMMAND") with a freshly created maven project and running `mvn install` produces the following output:
$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-exec-testcase
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
...
[INFO] [install:install {execution: default-install}]
[INFO] Installing /home/pascal/Projects/maven-exec-testcase/target/maven-exec-testcase-1.0-SNAPSHOT.jar to /home/pascal/.m2/repository/com/mycompany/app/maven-exec-testcase/1.0-SNAPSHOT/maven-exec-testcase-1.0-SNAPSHOT.jar
[INFO] [exec:exec {execution: my-exec}]
[INFO] pom.xml
[INFO] src
[INFO] target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12 seconds
[INFO] Finished at: Tue Jan 05 19:26:04 CET 2010
[INFO] Final Memory: 11M/75M
[INFO] ------------------------------------------------------------------------
As we can see, the command is executed at the end of the `install` phase (after the copy of the artifact to the local repository).
And if you really don't want to add the snippet to your pom, then you'll have to explicitly call `exec:exec` after `install` on the command line as suggested by whaley.
Problem
I want to run a simple exec command post maven install phase. What is the simplest way possible to achieve this? (without adding new plugins)