[ 
https://issues.apache.org/jira/browse/MNG-8051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17852391#comment-17852391
 ] 

James Howe edited comment on MNG-8051 at 6/5/24 11:03 AM:
----------------------------------------------------------

*I* have no control over how these dependencies require their own dependencies 
and how they should be used by me.

I also know exactly how and why Maven resolved it like that. However, that 
results in a failed build if you actually use those dependencies.

`provided` is present on the compile-time classpath but not included at 
runtime. `runtime` is the opposite. One dependency needs it at compile time 
(because it has APT hooks), and the other needs it only at runtime.

The same problem would arise in any situation where the "closest" resole is 
`runtime` but any other dependency needs it at compile time (`provided` or 
`compile`). If Maven had this requested feature, then that problem would solve 
itself automatically.


was (Author: jameshowe):
**I** have no control over how these dependencies require their own 
dependencies and how they should be used by me.

I also know exactly how and why Maven resolved it like that. However, that 
results in a failed build if you actually use those dependencies.

`provided` is present on the compile-time classpath but not included at 
runtime. `runtime` is the opposite. One dependency needs it at compile time 
(because it has APT hooks), and the other needs it only at runtime.

The same problem would arise in any situation where the "closest" resole is 
`runtime` but any other dependency needs it at compile time (`provided` or 
`compile`). If Maven had this requested feature, then that problem would solve 
itself automatically.

> Combine dependency scopes instead of overriding
> -----------------------------------------------
>
>                 Key: MNG-8051
>                 URL: https://issues.apache.org/jira/browse/MNG-8051
>             Project: Maven
>          Issue Type: Improvement
>          Components: Dependencies
>    Affects Versions: 3.9.6
>            Reporter: James Howe
>            Priority: Minor
>
> I discovered this situation when combining these dependencies:
> {code:xml}
> <dependency>
>   <groupId>org.hibernate.orm</groupId>
>   <artifactId>hibernate-core</artifactId>
>   <version>6.4.1.Final</version>
>   <scope>compile</scope>
> </dependency>
> <dependency>
>   <groupId>io.github.openfeign.querydsl</groupId>
>   <artifactId>querydsl-apt</artifactId>
>   <classifier>jpa</classifier>
>   <version>6.0.2</version>
>   <scope>provided</scope>
> </dependency>
> {code}
> 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 {{<dependencyManagement>}}, it would 
> be nice if Maven did this automatically.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to