Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run maven exec-maven-plugin as last step

Tags:

maven-2

maven

I want to execute a command line script with exec-maven-plugin after "mvn test" How do I set this up under pom.xml?

like image 980
fruitJuice Avatar asked Feb 24 '11 20:02

fruitJuice


2 Answers

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>
like image 199
Jan Avatar answered Oct 11 '22 01:10

Jan


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.

like image 40
timomeinen Avatar answered Oct 11 '22 01:10

timomeinen