Eliminating recursive Maven dependency
Let's say I'm developing project A that depends on projects B and JUnit-11.
A -> junit-11 and B
Project B depends on projects C and JUnit-8. but it is already packaged and I have no control over its contents.
B -> junit-8 and C
The C project also depends on jUnit-8.
C -> junit-8
Now the problem is when I try to build my project (project A) it also gets jUnit-8 which breaks the compilation. I can exclude project B's dependency on jUnit-8 when defining this in my pom.xml, but that does not apply to project C's dependency. As a result, jUnit-8 is still loading and breaking my project.
here is the associated pom.xml:
Project A (My Project) :pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>B</groupId>
<artifactId>B</artifactId>
<version>1.0</version>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</dependency>
</dependencies>
Project B (Existing project):pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8</version>
</dependency>
<dependency>
<groupId>C</groupId>
<artifactId>C</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
Project C (Existing project):pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8</version>
</dependency>
</dependencies>
Any advice on how to define a recursive exception excluding jUnit-8 across all sub-dependencies?
+3
source to share