I'm not sure if this is support by Maven or not. I appreciate any help I can get.
I have a parent pom that defines a dependency and an exclusion. I can't change the parent pom:
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
<exclusions>
<!-- this exclusion needs to be inherited by all children -->
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</exclusion>
</exclusions>
</dependency>
Then in the child pom, I have a need to exclude a different dependency from that same dependency in the parent. Like so
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
<exclusions>
<!-- this exclusion is just for the child -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
But if I do that, the child will have the slf4j jar excluded (correctly), but it will NOT have the spring-cloud-config-server jar excluded, unless if I restate the parent exclusion in the child declaration of that dependency.
I realize I could just copy it, but that's messy, and I realize that it would be easy to push the child's exclusion up to the parent, but then I'd be forcing that exclusion on all the other children.
What I'd like is for Maven to merge the dependency exclusion information when the same dependency is declared differently in the parent and child.
Is that possible?
In your parent pom:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0</version>
<exclusions>
<!-- this exclusion needs to be inherited by all children -->
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
In your child pom:
<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<exclusions>
<!-- this exclusion is just for the child -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With