Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Eclipse Maven saying dependencies of same version are conflicting?

When I have a dependency listed more than once in my dependency tree, even if all versions of that dependency are the same, Eclipse will say (in the Dependency Hierarchy tab of a POM) that all but one are "(omitted for conflict with X.X.X)". The group ID, artifact ID, and version will all be the same.

Here's a simple example with a randomly chosen dependency. Notice maven-model and maven-artifact.

maven-core dependency conflict same versions

I'm using Eclipse Mars (4.5.0)

This doesn't seem to have any affect on anything, besides the misleading messages in the UI. It's just pretty annoying to see "omitted for conflict..." all over the place, especially if I'm wanting to see the true conflicts.

like image 667
tobii Avatar asked Oct 06 '15 18:10

tobii


People also ask

How do you resolve dependency conflicts in Maven?

Enforcer can help developers solve dependency conflicts in Maven by analyzing all libraries declared in the POM file. The plugin uses a lot of different rules, but we are only interested in one: dependencyConvergence – ensures all dependencies converge to the same version.

Does Maven override dependency version?

By taking advantage of Maven's nearest definition logic, developers can override the version of a dependency by declaring it on the root pom. xml file.

How do I exclude a specific version of a dependency in Maven?

Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.

How does Maven determine dependency version?

Maven chooses the version of the dependency that is nearest in the dependency tree. This is explained very well in the Maven documentation: "nearest definition" means that the version used will be the closest one to your project in the tree of dependencies, eg.


1 Answers

The "Dependency Hierarchy" tab of Eclipse is populated by the M2Eclipse plugin. And, unfortunately, it seems this is hard-coded inside the M2Eclipse plugin source code. Whatever the reason a dependency was omitted (duplicate, version conflict...), the M2Eclipse plugin will add the label "omitted for conflict with".

Note that this is not the case of the tree goal of the maven-dependency-plugin, from which this tab mimics the output. By default, the command mvn dependency:tree will not show dependencies that were omitted. If the verbose flag is set to true, then the output will show every dependency that were omitted for: being a duplicate of another; conflicting with another's version and/or scope; and introducing a cycle into the dependency tree.

I couldn't find a bug for this so you could maybe file an enhancement request, through their Bugzilla, to ask that the plugin adheres more with the output of dependency:tree (for example showing the real reason a dependency was omitted, instead of the current default) and to add an option to switch between verbose and not verbose mode.

like image 177
Tunaki Avatar answered Nov 15 '22 20:11

Tunaki