I want to execute a command line script with exec-maven-plugin after "mvn test" How do I开发者_StackOverflow中文版 set this up under pom.xml?
You can just take the example from the project website and have to add a phase to the execution. I've just tested with this pom below and it works fine.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.stackoverflow</groupId>
<artifactId>q5110133</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>Test.bat</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>c:\temp\test.bat</executable>
<!-- optional -->
<workingDirectory>C:\temp</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
The point of the ordering is, that you have to choose a phase for execution, which is behind the test-phase. You can see this in the Maven Build Lifecycle.
For example, you could use prepare-package which is the phase directly after the test phase.
BTW: Plugins, when configured in the same lifecycle, are executed in the order in which they are listed in the pom.xml.
精彩评论