运行maven exec-maven-plugin作为最后一步

fru*_*ice 10 maven-2 maven

我想在"mvn test"之后用exec-maven-plugin执行命令行脚本如何在pom.xml下设置它?

Jan*_*Jan 12

您可以从项目网站获取示例,并且必须为执行添加阶段.我刚用下面这个pom进行测试,它运行正常.

    <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>
Run Code Online (Sandbox Code Playgroud)


tim*_*nen 7

排序的重点是,您必须选择执行阶段,这是测试阶段的后面.您可以在Maven构建生命周期中看到这一点.

例如,您可以使用prepare-package,它是测试阶段之后的阶段.

BTW:插件在同一生命周期中配置时,按照pom.xml中列出的顺序执行.