apache / apache/maven

[MNG-8051] Combine dependency scopes instead of overriding

Open
#10,858 2 comments 1 reaction 0 assignees View on GitHub
enhancement priority:minor
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[James Howe](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jameshowe)** opened **[MNG-8051](https://issues.apache.org/jira/browse/MNG-8051?redirect=false)** and commented

I discovered this situation when combining these dependencies:

```xml

org.hibernate.orm
hibernate-core
6.4.1.Final
compile

io.github.openfeign.querydsl
querydsl-apt
jpa
6.0.2
provided

```

This results in two copies of a transient dependency on `jakarta.inject:jakarta.inject-api`, one with `runtime` scope and one with `provided` scope. In my case, Maven resolves this to a single dependency at `runtime` scope, which causes the build to fail.

Instead, the two scopes should logically combine into the `compile` scope. While this can be manually achieved with ``, it would be nice if Maven did this automatically.

---

**Affects:** 3.9.6

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the dependency combination described for Maven 3.9.6 and trace dependency scope resolution for the two jakarta.inject:jakarta.inject-api copies. Done means the scopes combine to compile rather than resolving to runtime, with a regression test covering the provided example.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.