I've noticed some pattern in projects's poms. There is a dependency graph like this: your Project A -> some other Project B -> B's dependency Project C. Project B is declared as a dependency in A's pom and B's dependency C excluded from B and re-declared as a direct dependency of project A. What is the point of this exclusion if Maven docs openly says it takes the "nearest" dependency, so if you declare it directly then Maven uses that version instead any of transitive ones?
Asked
Active
Viewed 86 times
1 Answers
1
You normally do this to change the version or scope of the dependency. So you may exclude dependency to C from dependency to B, which leaves you without dependency to C. Now you add a direct dependency to C in A, with another version.
The documentation is still right, every artifact should declare what it directly needs. But in cases of conflicts the above pattern is the rescue.

Stefan Isele - prefabware.com
- 8,905
- 4
- 28
- 31
-
In case of conflicts the "nearest" dependency wins that is what docs says. Just declare it as a top level dependency and maven should use exactly that version regardless transitive dependencies. So why do you need to exclude it then? – MaxNevermind Feb 23 '16 at 20:40