gpt4 book ai didi

maven - 执行插件目标时 : before or after declared phase?

转载 作者:行者123 更新时间:2023-12-05 00:27:45 28 4
gpt4 key购买 nike

我有一个关于 maven pom 的问题。我有这个 pom.xml

<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Hello world!</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

目标运行何时执行?在包装阶段之前还是之后?

(对于 Maven 生命周期,请参阅 Maven lifecycle )

最佳答案

插件目标是执行 声明阶段的开始( package ),以及下一阶段开始之前( pre-integration-test )。

在这个场景 maven 命令中

mvn package

应该打印 Hello World
一个阶段多次执行:

Note: In Maven 2.0.5 and above, multiple goals bound to a phase are executed in the same order as they are declared in the POM, however multiple instances of the same plugin are not supported. Multiple instances of the same plugin are grouped to execute together and ordered in Maven 2.0.11 and above).





When multiple executions are given that match a particular phase, they are executed in the order specified in the POM, with inherited executions running first.



来源: Introduction to the Build Lifecycle

关于maven - 执行插件目标时 : before or after declared phase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20074841/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com