Maven 战争期间运行安特伦:爆炸

Maven 战争期间运行安特伦:爆炸,maven,war,maven-antrun-plugin,exploded,Maven,War,Maven Antrun Plugin,Exploded,对于Maven构建,我需要在使用war插件创建分解目录后复制一些文件。战争期间/之后是否可以运行antrun插件:爆炸目标?如果是这样,我该怎么做?我试过: <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution>

对于Maven构建,我需要在使用war插件创建分解目录后复制一些文件。战争期间/之后是否可以运行antrun插件:爆炸目标?如果是这样,我该怎么做?我试过:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
        <execution>
          <phase>war</phase>
          <goals>
            <goal>exploded</goal>
          </goals>
          <configuration>
            <tasks>
              <echo>Running ant task...</echo>
            </tasks>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

maven antrun插件
战争
爆炸了的
正在运行ant任务。。。
和其他一些变体,但似乎无法运行


理想情况下,如果我进行一场全面的战争,我希望ant任务能够运行:战争也是如此,但当我来到这座桥时,我会跨越这座桥。

至少有两种方法可以实现它:

使用直接调用插件

调用
mvnwar:exploded
order
mvnwar:war
时,您只调用特定插件的特定目标。没有其他插件被执行。pom.xml中定义的执行不相关。因此,您只能直接调用几个插件目标,例如
mvnwar:un:run

但是在构建多个模块时要小心:
mvnwar:ansrun:run
在每个模块的war插件之后运行ansrun。而
mvn战争:爆发;mvn antrun:run
为所有模块运行war插件,然后为所有模块运行antrun

使用插件的生命周期绑定

当调用
mvn预集成测试时,您可以调用多达预集成测试的所有阶段。您可以在“包”阶段为目标“分解”定义war插件执行,在“预集成测试”阶段为目标“运行”定义antrun执行


默认生命周期中没有“战争”阶段。因此,您上面的示例在默认生命周期中不起作用。对于具有自定义阶段的自定义生命周期,您需要自定义插件