【问题标题】:Overriding Maven plugin goal definition for a given execution id覆盖给定执行 ID 的 Maven 插件目标定义
【发布时间】:2011-07-20 09:56:51
【问题描述】:

似乎无法覆盖插件执行的目标定义。

假设我有一个 Jetty 的父配置,它定义了一个

                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>

现在我想在本地为一个特定项目实现目标爆炸

如果我尝试用

覆盖本地项目中的父定义
                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run-exploded</goal>
                        </goals>
                    </execution>

然后我的有效pom就变成了

                    <execution>
                        <id>start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run</goal>
                            <goal>run-exploded</goal>
                        </goals>
                    </execution>

我很惊讶,因为我一直认为它会覆盖。

这是 Maven3 中的新行为吗?

是否有一种覆盖行为而不是当前行为?

【问题讨论】:

标签: plugins configuration maven


【解决方案1】:

我发现的方法是禁用继承的配置并创建一个新的:

                    <execution>
                        <id>start-jetty</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>my-start-jetty</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>run-exploded</goal>
                        </goals>
                    </execution>

【讨论】:

    【解决方案2】:

    嗯,这是按照设计的方式工作的继承。您应该考虑从父 pom 中删除您的码头配置并将其放入配置文件中,或者您尝试使用值为 false 的 &lt;inherited&gt; 元素,看看这是否适合您。

    【讨论】:

    • 很高兴了解继承,但对码头插件有一个奇怪的行为,此外,这不是我想要的,我需要继承。
    • 如果你从全局角度解释这个问题,与其说是运行 Jetty 本身,不如说是子 pom 中的插件覆盖。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    • 2014-03-29
    • 2012-08-20
    • 2023-03-16
    • 1970-01-01
    相关资源
    最近更新 更多