Run a script after maven install
Use the http://www.mojohaus.org/exec-maven-plugin/ exec-maven-plugin, in conjunction with an "executions" configuration block that specifies the installation phase. Make sure it is after your maven-install-plugin as plugins are ran in order (within the same phase)
(in build/plugins) <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.5.0</version> <executions> <execution> <phase>install</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>do-something.sh</executable> <workingDirectory>/some/dir</workingDirectory> <arguments> <argument>--debug</argument> <argument>with_great_effect</argument> </arguments> </configuration> </execution> </executions> </plugin>
For a purely maven-driven approach, the answer you're looking for is the exec
goal of exec-maven-plugin
, and this answer applies: https://stackoverflow.com/a/2008258/3403663
EDIT: OP indicates the above doesn't work for him.
Alternative approach: I just tried the following in my own project, and it executes ls
at the very end of the install phase, after artifacts have been deployed.
mvn clean install exec:exec -Dexec.executable="/bin/ls" -Dexec.args="/etc"
Otherwise, you could always just wrap the whole thing in a script:
#!/bin/bashset -o errexitmvn clean install<your other commands here>
Why can't you do something like this? This will go after the normal maven install phase.
EDIT: If you add the maven-install-plugin before it, maven will run each in the order they are in the pom.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <phase>install</phase> <configuration> <tasks> <exec dir="${project.basedir}" executable="${project.basedir}/src/main/sh/do-something.sh" failonerror="true"> <arg line="arg1 arg2 arg3 arg4" /> </exec> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin>
Source: maven-antrun-plugin