'How does the Maven dependency resolution handle refined/conflicting version ranges?
I have studied the Maven documentation on poms/dependency mechanism and the "Complete Reference" Book to understand the dependency resolution algorithm and I think that I understand the general approach. Like the idea of mediation, management, scope, exclusions, or optional dependencies.
While it is clear to me what happens when explicit hard/soft versions are used with one particular version (like <version>1.2.3</version>), I could not find information how mediation affects version ranges... or in general, how ranges are being resolved across a dependency set. Assuming I have the following dependency definition for A
A
+-B (1.0.0, 2.0.0)
|-C
+-B (1.5.0, 2.0.0)
In which A defines a dependency on B, in the version range (1.0.0, 2.0.0), and on C, which also depends on B, but in the range (1.5.0, 2.0.0). Which version of B would be used? Does the dependency algorithm try to unite and solve all these constraints and end up with the newest version that lies in the 1.5.0-2.0.0 range, or does again the closer definition win and completely override the definition in the transitive dependency?
Second example, assuming the two ranges would not overlap (e.g., A depends on B (1.0.0, 1.1.0) and C on B (1.2.0, 1.3.0)), I would expect that (given that both are soft constraints) Maven would just pick the newest version of B that matches the version range defined in A. Or would this crash like a violated hard requirement?
The same two questions can also be asked for dependencyManagement sections or "Bill-of-material" imports ("pom dependency"), but I would expect that they follow the same logic.
I would highly appreciate an explanation or any pointers to documentation that sheds light on this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
