Maven throws a strange warning while builduing our multi-module project. I'm just referencing the jar and test-jar of the same project in another project. Both dependencies have test scope. Im running Maven 3.3.1 and cannot upgrade the version easily.
Does anyone of you have an idea how I could solve the problem without getting this warning from maven?
pom.xml of ProjectA:
<dependency> <!-- This is line 130 -->
<groupId>${project.groupId}</groupId>
<artifactId>projectB</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>projectB</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
Warnings from maven (anonymized):
[WARNING] Some problems were encountered while building the effective model for org.group.ProjectA:1.0-SNAPSHOT [WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: ${project.groupId}:org.group.ProjectB:jar -> duplicate declaration of version ${project.version} @ org.group.ProjectA, /var/lib/jenkins/jobs/nicejob/workspace/org.group.ProjectA/pom.xml, line 130, column 15
Maven can automatically bring in these artifacts, also called transitive dependencies. Version collision happens when multiple dependencies link to the same artifact, but use different versions.
Maven won't allow any other either. Build will fail if version is not found.
Looking at test-jar documentation I would say the two artifact are basically the same one, and that the "test-jar" one is not expected to be used aparte from test phase since it contains test classes.
A good approach could be:
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