apache / apache/maven

[MNG-6663] overriding parent dependency management doesn't work for transitive dependencies

Open
#8,570 4 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[Alireza Ghassemi](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=ravenblackdusk)** opened **[MNG-6663](https://issues.apache.org/jira/browse/MNG-6663?redirect=false)** and commented

overriding the dependencies of a parent POM is possible by setting the dependency version explicitly in the child POM which makes sense; since a parent POM is "suggesting" dependency versions for children that don't know which version to use and a child that knows exactly which version they need can ignore their parents "suggestion". however that is not the case for transitive dependencies of the dependency explicitly versioned in the child.

example POM:

[^pom.xml]

mvn dependency:tree output:

[INFO] foo.bar:kotlin-test:jar:1.0-SNAPSHOT
[INFO] - org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.3.31:compile
[INFO]    +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.2.71:compile
[INFO]    |  +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.2.71:compile
[INFO]    |  - org.jetbrains:annotations:jar:13.0:compile
[INFO]    - org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.2.71:compile

expected:

[INFO] foo.bar:kotlin-test:jar:1.0-SNAPSHOT
[INFO] - org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.3.31:compile
[INFO]    +- org.jetbrains.kotlin:kotlin-stdlib:jar:1.3.31:compile
[INFO]    |  +- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.3.31:compile
[INFO]    |  - org.jetbrains:annotations:jar:13.0:compile
[INFO]    - org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.3.31:compile

 

since 'kotlin-stdlib-jdk8:1.3.31' was compiled with 'kotlin-stdlib:1.3.31' runtime exceptions will happen; yet nobody needs 'kotlin-stdlib:1.2.71'

---

**Affects:** 3.6.1

**Attachments:**
- [pom.xml](https://issues.apache.org/jira/secure/attachment/12979143/pom.xml) (_1.18 kB_)
- [pom.xml](https://issues.apache.org/jira/secure/attachment/12970031/pom.xml) (_830 bytes_)

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.