0

Maven plugin and its dependency defined in parent pom and I do not want my child pom to include that plugin dependency.

For example, if there is 1 parent and 100 children, 99 use that plugin and want to exclude that plugin in one child.

How could we achieve this one?

user8862215
  • 11
  • 1
  • 3
  • Possible duplicate of [Struggling with Maven parent/child plugin configuration inheritance](https://stackoverflow.com/questions/14648556/struggling-with-maven-parent-child-plugin-configuration-inheritance) – question_maven_com Oct 31 '17 at 13:45
  • You may find this useful: [Is there anyway to exclude artifacts inherited from a parent POM?](https://stackoverflow.com/questions/2681759/is-there-anyway-to-exclude-artifacts-inherited-from-a-parent-pom). – gjoranv Oct 31 '17 at 18:50

2 Answers2

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>

user8862215
  • 11
  • 1
  • 3
0

Instead of configuring the plugin in <plugins> section, you should do the job in <pluginManagement>

see https://maven.apache.org/pom.html#Plugin_Management for more details

hboutemy
  • 301
  • 2
  • 8