Reputation: 1849
Let's assume we have a Project A.
In this case, how would Maven resolve the conflict?
Upvotes: 3
Views: 5285
Reputation: 1849
I found this explanation and it was really helpful to me.
Nearest definition means that the version used will be the closest one to your project in the tree of dependencies,
eg. if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0
Upvotes: 6
Reputation: 616
It'd build with Project B v 1.0
You can use http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html to see, that it omitted B 2.0 cause 1.0 is nearer.
from page above:
by default Maven resolves version conflicts with a nearest-wins strategy.
Output'd be something like that:
[INFO] [dependency:tree]
[INFO] Project A
[INFO] +- Project-B:jar:1.0:compile
[INFO] \- Project-C:jar:2.0:compile
[INFO] \- (Project-B:jar:2.0:compile - ommited for conflicts with 1.0)
Upvotes: 2