【问题标题】:Running antrun during war:exploded战争期间运行antrun:爆炸
【发布时间】:2011-03-16 12:44:11
【问题描述】:

对于 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 war maven-antrun-plugin exploded


    【解决方案1】:

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

    使用插件的直接调用

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

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

    使用插件的生命周期绑定

    当调用mvn pre-integration-test 时,您调用default lifecycle 的所有阶段直到预集成测试。您可以在“package”阶段为“exploded”目标定义一个war插件执行,在“pre-integration-test”阶段为“run”目标定义一个antrun执行。


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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-04
      • 2015-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多