You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Tamas Cservenak (Jira)" <ji...@apache.org> on 2024/06/05 10:43:00 UTC
[jira] [Comment Edited] (MNG-8051) Combine dependency scopes instead of overriding
[ https://issues.apache.org/jira/browse/MNG-8051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17852375#comment-17852375 ]
Tamas Cservenak edited comment on MNG-8051 at 6/5/24 10:42 AM:
---------------------------------------------------------------
This sounds wrong: if you need jakarta.inject-api in "compile" scope, it means you compile against it (is best practice anyway) to declare it as compile dependency (and not rely on 3rd party dependency to "pull it in for you").
Moreover, hibernate-core that you declare in "compile" scope declares inject in "runtime" scope:
[https://repo.maven.apache.org/maven2/org/hibernate/orm/hibernate-core/6.4.1.Final/hibernate-core-6.4.1.Final.pom]
While the other dependency "querydsl-apt" you put in provided scope (and that "transforms" whole subtree of that node to "provided", as it is initially in "compile"):
[https://repo.maven.apache.org/maven2/io/github/openfeign/querydsl/querydsl-apt/6.0.2/querydsl-apt-6.0.2.pom]
How could Maven out of these deduce you want "compile" scope Inject? Again, you declared two deps, the one in "compile" scope sets inject to "runtime", while other is put by you in "provided" scope.
Maven chooses the scope of node that is "closer":
{noformat}
[cstamas@angeleyes MNG-8051]$ mvn eu.maveniverse.maven.plugins:toolbox:tree -DverboseTree
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< org.cstamas:mng-8051 >-----------------------
[INFO] Building mng-8051 1.0.0
[INFO] from pom.xml
[INFO] -------------------------------[ jar ]--------------------------------
[INFO]
[INFO] — toolbox:0.1.23:tree (default-cli) @ mng-8051 —
[INFO] org.cstamas:mng-8051:jar:1.0.0
[INFO] +- org.hibernate.orm:hibernate-core:jar:6.4.1.Final [compile]
[INFO] | +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0 [compile]
[INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:2.0.1 [compile]
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.5.0.Final [runtime]
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:6.0.6.Final [runtime]
[INFO] | +- io.smallrye:jandex:jar:3.1.2 [runtime]
[INFO] | +- com.fasterxml:classmate:jar:1.5.1 [runtime]
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.14.7 [runtime]
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0 [runtime]
[INFO] | | - jakarta.activation:jakarta.activation-api:jar:2.1.0 [runtime]
[INFO] | +- org.glassfish.jaxb:jaxb-runtime:jar:4.0.2 [runtime]
[INFO] | | - org.glassfish.jaxb:jaxb-core:jar:4.0.2 [runtime]
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0 [runtime] (nearer exists)
[INFO] | | +- jakarta.activation:jakarta.activation-api:jar:2.1.1 [runtime] (conflicts with 2.1.0)
[INFO] | | +- org.eclipse.angus:angus-activation:jar:2.0.0 [runtime]
[INFO] | | | - jakarta.activation:jakarta.activation-api:jar:2.1.1 [runtime] (conflicts with 2.1.0)
[INFO] | | +- org.glassfish.jaxb:txw2:jar:4.0.2 [runtime]
[INFO] | | - com.sun.istack:istack-commons-runtime:jar:4.1.1 [runtime]
[INFO] | +- jakarta.inject:jakarta.inject-api:jar:2.0.1 [runtime]
[INFO] | - org.antlr:antlr4-runtime:jar:4.13.0 [runtime]
[INFO] - io.github.openfeign.querydsl:querydsl-apt:jar:jpa:6.0.2 [provided]
[INFO] +- io.github.openfeign.querydsl:querydsl-codegen:jar:6.0.2 [provided]
[INFO] | +- io.github.openfeign.querydsl:querydsl-core:jar:6.0.2 [provided]
[INFO] | | +- com.mysema.commons:mysema-commons-lang:jar:0.2.4 [provided]
[INFO] | | - jakarta.annotation:jakarta.annotation-api:jar:2.1.1 [provided] (nearer exists)
[INFO] | +- io.github.openfeign.querydsl:codegen-utils:jar:6.0.2 [provided]
[INFO] | | +- org.eclipse.jdt:ecj:jar:3.33.0 [provided]
[INFO] | | - io.github.classgraph:classgraph:jar:4.8.165 [provided] (nearer exists)
[INFO] | +- jakarta.inject:jakarta.inject-api:jar:2.0.1 [provided] (nearer exists)
[INFO] | - io.github.classgraph:classgraph:jar:4.8.165 [provided]
[INFO] +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0 [provided] (nearer exists)
[INFO] - jakarta.annotation:jakarta.annotation-api:jar:2.1.1 [provided]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.204 s
[INFO] Finished at: 2024-06-05T12:34:22+02:00
[INFO] ------------------------------------------------------------------------
[cstamas@angeleyes MNG-8051]${noformat}
was (Author: cstamas):
This sounds wrong: if you need jakarta.inject-api in "compile" scope, it means you compile against it (is best practice anyway) to declare it as compile dependency (and not rely on 3rd party dependency to "pull it in for you").
Moreover, hibernate-core that you declare in "compile" scope declares inject in "runtime" scope:
[https://repo.maven.apache.org/maven2/org/hibernate/orm/hibernate-core/6.4.1.Final/hibernate-core-6.4.1.Final.pom]
While the other dependency "querydsl-apt" you put in provided scope (and that "transforms" whole subtree of that node to "provided", as it is initially in "compile"):
[https://repo.maven.apache.org/maven2/io/github/openfeign/querydsl/querydsl-apt/6.0.2/querydsl-apt-6.0.2.pom]
How could Maven out of these deduce you want "compile" scope Inject? Again, you declared two deps, the one in "compile" scope sets inject to "runtime", while other is put by you in "provided" scope.
Maven chooses the scope of node that is "closer":
{noformat}
[cstamas@angeleyes MNG-8051]$ mvn eu.maveniverse.maven.plugins:toolbox:tree -DverboseTree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.cstamas:mng-8051 >------------------------
[INFO] Building mng-8051 1.0.0
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- toolbox:0.1.23:tree (default-cli) @ mng-8051 ---
[INFO] org.cstamas:mng-8051:jar:1.0.0
[INFO] +- org.hibernate.orm:hibernate-core:jar:6.4.1.Final [compile]
[INFO] | +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0 [compile]
[INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:2.0.1 [compile]
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.5.0.Final [runtime]
[INFO] | +- org.hibernate.common:hibernate-commons-annotations:jar:6.0.6.Final [runtime]
[INFO] | +- io.smallrye:jandex:jar:3.1.2 [runtime]
[INFO] | +- com.fasterxml:classmate:jar:1.5.1 [runtime]
[INFO] | +- net.bytebuddy:byte-buddy:jar:1.14.7 [runtime]
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0 [runtime]
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:2.1.0 [runtime]
[INFO] | +- org.glassfish.jaxb:jaxb-runtime:jar:4.0.2 [runtime]
[INFO] | | \- org.glassfish.jaxb:jaxb-core:jar:4.0.2 [runtime]
[INFO] | | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.0 [runtime] (nearer exists)
[INFO] | | +- jakarta.activation:jakarta.activation-api:jar:2.1.1 [runtime] (conflicts with 2.1.0)
[INFO] | | +- org.eclipse.angus:angus-activation:jar:2.0.0 [runtime]
[INFO] | | | \- jakarta.activation:jakarta.activation-api:jar:2.1.1 [runtime] (conflicts with 2.1.0)
[INFO] | | +- org.glassfish.jaxb:txw2:jar:4.0.2 [runtime]
[INFO] | | \- com.sun.istack:istack-commons-runtime:jar:4.1.1 [runtime]
[INFO] | +- jakarta.inject:jakarta.inject-api:jar:2.0.1 [runtime]
[INFO] | \- org.antlr:antlr4-runtime:jar:4.13.0 [runtime]
[INFO] \- io.github.openfeign.querydsl:querydsl-apt:jar:jpa:6.0.2 [provided]
[INFO] +- io.github.openfeign.querydsl:querydsl-codegen:jar:6.0.2 [provided]
[INFO] | +- io.github.openfeign.querydsl:querydsl-core:jar:6.0.2 [provided]
[INFO] | | +- com.mysema.commons:mysema-commons-lang:jar:0.2.4 [provided]
[INFO] | | \- jakarta.annotation:jakarta.annotation-api:jar:2.1.1 [provided] (nearer exists)
[INFO] | +- io.github.openfeign.querydsl:codegen-utils:jar:6.0.2 [provided]
[INFO] | | +- org.eclipse.jdt:ecj:jar:3.33.0 [provided]
[INFO] | | \- io.github.classgraph:classgraph:jar:4.8.165 [provided] (nearer exists)
[INFO] | +- jakarta.inject:jakarta.inject-api:jar:2.0.1 [provided] (nearer exists)
[INFO] | \- io.github.classgraph:classgraph:jar:4.8.165 [provided]
[INFO] +- jakarta.persistence:jakarta.persistence-api:jar:3.1.0 [provided] (nearer exists)
[INFO] \- jakarta.annotation:jakarta.annotation-api:jar:2.1.1 [provided]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.204 s
[INFO] Finished at: 2024-06-05T12:34:22+02:00
[INFO] ------------------------------------------------------------------------
[cstamas@angeleyes MNG-8051]${noformat}
> 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)