run maven exec-maven-plugin as last step

两盒软妹~` 提交于 2019-12-09 02:51:39

问题


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


回答1:


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>



回答2:


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.



来源:https://stackoverflow.com/questions/5110133/run-maven-exec-maven-plugin-as-last-step

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!