【问题标题】:How to remove a plugin configuration defined in parent pom from child pom如何从子 pom 中删除父 pom 中定义的插件配置
【发布时间】:2016-01-19 23:05:58
【问题描述】:

我有一个父 pom 在 pluginManagement 中为一个插件定义了一些配置项,其中有一个特定的配置。我不想在孩子 pom 中。

我尝试覆盖我的子 pom 中的其他配置项,这可行,但“删除”配置项似乎不起作用。 “删除”是指我尝试不填写任何内容,例如:

<configuration>
  <itemIdontWant></itemIdontWant>
</configuration>

上面没有工作,我仍然得到相同的配置。在编译过程中。我可以填写一些垃圾来使这个项目无效,但我想要正确的方法来“删除”它。有什么帮助吗?

【问题讨论】:

    标签: maven maven-3 pom.xml parent-pom


    【解决方案1】:

    您可以简单地尝试以下方法:

    <configuration>
      <itemIdontWant combine.self="override"></itemIdontWant>
    </configuration>
    

    上面的问题可能是,如果您想将其设置为空,则插件的默认值将成为该值。

    此外,您可以使用以下方法更改配置的继承:

    <build>
      <plugins>
        <plugin>
          <inherited>false</inherited>
          <groupId>...</groupId>
          <artifactId>..</artifactId>
        </plugin>
      </plugins>
    </build>
    

    以上部分的文档可以在这里找到:https://maven.apache.org/pom.html

    【讨论】:

    • 是的,额外的 combine.self="override" 起作用了。如果您重新定义了值但在设置空值时需要这样做,有什么理由不需要这样做?
    • 继承标签进入哪个配置,父级还是子级? Apache 文档也没有指明是哪一个。
    猜你喜欢
    • 1970-01-01
    • 2018-04-12
    • 1970-01-01
    • 2018-10-08
    • 2011-06-17
    • 2018-08-09
    • 2021-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多