The scenario: my project enables the maven-enforcer-plugin dependencyConvergence rule. It depends on a library that has corrected its own dependency convergence by using a dependencyManagement declaration, but it doesn't seem to affect the resolution of the dependency versions downstream.
An example of the type of error message I'm talking about (note that both versions are inherited by d
as transitive dependencies under the c
module):
Dependency convergence error for org.apache.commons:commons-lang3:3.0 paths to dependency are:
+-com.example:d:1.0-SNAPSHOT
+-com.example:c:1.0-SNAPSHOT
+-com.example:b:1.0-SNAPSHOT
+-org.apache.commons:commons-lang3:3.0
and
+-com.example:d:1.0-SNAPSHOT
+-com.example:c:1.0-SNAPSHOT
+-org.apache.commons:commons-lang3:3.1
mvn dependency:tree
shows similar inconsistency. c
has the transitive version managed:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ c ---
[INFO] com.example:c:jar:1.0-SNAPSHOT
[INFO] +- com.example:b:jar:1.0-SNAPSHOT:compile
[INFO] | \- (org.apache.commons:commons-lang3:jar:3.1:compile - version managed from 3.0; omitted for duplicate)
[INFO] \- org.apache.commons:commons-lang3:jar:3.1:compile
but d
shows it as a conflict:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ d ---
[INFO] com.example:d:jar:1.0-SNAPSHOT
[INFO] \- com.example:c:jar:1.0-SNAPSHOT:compile
[INFO] +- com.example:b:jar:1.0-SNAPSHOT:compile
[INFO] | \- (org.apache.commons:commons-lang3:jar:3.0:compile - omitted for conflict with 3.1)
[INFO] \- org.apache.commons:commons-lang3:jar:3.1:compile
It seems like this is a potentially endless problem. If I correct it using dependencyManagement in d
, then I'm just pushing the problem downstream to any consumers of d
. I can avoid the error by excluding the transitive dependency in the c
project's pom, but that's why I have the dependencyManagement declaration in c
!
I think this is a bug in Maven, or maybe in the enforcer plugin. Am I missing something? What is the right way to deal with this situation?
Is this a case of http://jira.codehaus.org/browse/MNG-3038 (open since 2007!)? In my case, the dependency is used everywhere along the trail.