apache / apache/maven

[MNG-6357] Dependency order should be nearest first

Open
#7,501 11 comments 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 40m
Merged PRs (30d)
275

Description

**[Robert Scholte](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=rfscholte)** opened **[MNG-6357](https://issues.apache.org/jira/browse/MNG-6357?redirect=false)** and commented

In case of version conflicts, the nearest wins. However, the dependency order is simply based on tree walking. In the rare case that a transitive dependency of the first direct dependency contains the same class as a latter direct dependency, the code is compiled against the first one, which is odd.

It would make more sense if direct dependencies are the first ones on the classpath, followed by the first level transitive dependencies, etc. This will make the explanation equal to version conflict resolution: nearest wins.

I don't expect real issues due to this change, otherwise we would have had this issue much earlier. This should become the new default order, however there should be a system property to get the original order, just in case somebody needs it.

 

Current workaround: make the critical dependency the first direct dependency.

---

**Issue Links:**
- [MCOMPILER-317](https://issues.apache.org/jira/browse/MCOMPILER-317) Plugin generates wrong modulepath (dependencies listed in wrong order)

- [MNG-7852](https://issues.apache.org/jira/browse/MNG-7852) Use all the versions for dependency resolution rather than "nearest first" or "declared first"
(_**"is superceded by"**_)

**Remote Links:**
- [GitHub Pull Request #47
](https://github.com/apache/maven-integration-testing/pull/47)
- [GitHub Pull Request #281
](https://github.com/apache/maven/pull/281)

2 votes, 9 watchers

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.