run maven exec-maven-plugin as last step

后端 未结 2 386
独厮守ぢ
独厮守ぢ 2021-01-11 15:12

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

相关标签:
2条回答
  • 2021-01-11 15:39

    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.

    0 讨论(0)
  • 2021-01-11 15:49

    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>
    
    0 讨论(0)
提交回复
热议问题