Reputation: 79
I have a project that have some dependencies that are the same but with different versions. Example:
Is there a configuration that allows me to force maven to always get the higher version of the dependencies with conflict?
Upvotes: 3
Views: 1746
Reputation: 12335
http://maven.apache.org/enforcer/enforcer-rules/requireUpperBoundDeps.html forces you to use and/or specify the latest version of all dependencies. So it's not an automatic get, but it matches your requirements.
Upvotes: 1
Reputation: 613
force maven to always get the higher version
You do not want to do that. There might be transitative dependecies that depend on the older versions that have different API from the newer versions.
What you wish to do is solve your dependecy problems at the source. Find out what needs an older dependecy and why. The see what you can do to resolve the conflict.
If the API is unchanged, you can declare the dependecies explicitely and exclude the old transitative, ex here we exclude xml-apis from xerces:
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
Using the above logic you can then declare the versions you need of the library. However, be careful not to end up with non-compiling code due to api changes between library versions.
Upvotes: 3