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

标签 maven maven-2 maven-3 maven-plugin

我有一个关于 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/

相关文章:

java - 为 aspectj 运行 JDK8

maven-3 - 如何在 Maven 中启动单个目标/执行

java - Android 库与本地 Maven 存储库一起使用

json - ClassNotFoundException : org. apache.commons.lang.xwork.StringUtils 与 Struts2 - JSON - JQuery

android - 使用 gradle maven-publish 插件导出的 Kotlin Android 库模块不添加依赖项

java - 多模块 Maven 项目中的 log4j 配置文件

maven-2 - 如何控制maven内置的jar中的pom.xml?

java - 使用什么框架来引导我的第一个生产 Scala 项目?

maven - 根据 JDK 更新版本选择 Maven 配置文件

Maven 内存不足构建失败