战争期间运行antrun:爆炸
对于 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>
以及其他几种变体,但似乎无法让它运行。
理想情况下,如果我进行全面的战争:战争,我也希望蚂蚁任务能够运行,但当我到达它时,我会跨过这座桥。
For a Maven build I need to copy some files after the exploded directory has been made with the war plugin. Is it possible to run the antrun plugin during/after the war:exploded goal? If so how would I do this? I've tried:
<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>
And several other variation but can't seem to get it to run.
Idealy I'd like the ant task to run if I do a full war:war too but I'll cross this bridge when I come to it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
至少有两种方法可以实现:
使用插件的直接调用
当调用
mvn war:exploded
或mvn 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
时,您调用了默认生命周期直至预集成测试。您可以在“package”阶段为目标“exploded”定义一个 war 插件执行,并在“pre-integration-test”阶段为目标“run”定义一个 antrun 执行。默认生命周期中没有阶段“战争”。因此,上面的示例不适用于默认生命周期。对于具有自定义阶段的自定义生命周期,您需要自定义插件。
There are at least two ways to achieve it:
Using direct invocation of plugins
When calling
mvn war:exploded
odermvn war:war
, you only call a specific goal of a specific plugin. No other plugin is executed. Executions defined in pom.xml are not relevant. As a consequence, you could only call several plugin goals directly, for examplemvn war:exploded antrun:run
.But be careful when building several modules:
mvn war:exploded antrun:run
runs antrun after the war plugin for each module. Whereasmvn war:exploded; mvn antrun:run
runs the war plugin for all modules and then antrun for all modules.Using lifecycle bindings of plugins
When calling
mvn pre-integration-test
, you call all phases of the default lifecycle up to pre-integration-test. You could define an war plugin execution for goal "exploded" in phase "package" and an antrun execution for goal "run" in phase "pre-integration-test".There is no phase "war" in the default lifecycle. So your example above won't work with the default lifecycle. And for a custom lifecycle with custom phases, you need custom plugins.