【问题标题】:Exclude parent pom plugin dependency in child pom在子 pom 中排除父 pom 插件依赖
【发布时间】:2018-04-12 14:39:44
【问题描述】:

Maven 插件及其在父 pom 中定义的依赖项,我不希望我的子 pom 包含该插件依赖项。

例如,如果有 1 个父级和 100 个子级,则 99 个使用该插件并希望在一个子级中排除该插件。

我们如何实现这一目标?

【问题讨论】:

标签: maven


【解决方案1】:
I found the answer. In parent pom, we should include child details as in below to remove this plugin dependency in child.
<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.17</version>
    <configuration>
      <classpathDependencyExcludes>
        <classpathDependencyExclude>${child-dependency-groupId}:${child-dependency-artifactId}</classpathDependencyExclude>
      </classpathDependencyExcludes>
    </configuration>
  </plugin>
</plugins>

【讨论】:

  • 欢迎来到 Stack Overflow!这实际上是评论/问题编辑,而不是答案。
【解决方案2】:

不要在&lt;plugins&gt; 部分配置插件,您应该在&lt;pluginManagement&gt; 中完成这项工作

查看https://maven.apache.org/pom.html#Plugin_Management了解更多详情

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 2016-12-17
    • 2019-03-31
    • 1970-01-01
    • 2023-03-10
    • 2021-02-27
    相关资源
    最近更新 更多