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

perdjesk edited comment on MRESOLVER-391 at 10/27/23 10:19 AM:
---------------------------------------------------------------

In the current state of your example, for dependency acme-lib-c the issues that 
might arise from difference between 1.0.0 and 2.0.0 version selection will be 
similar in test and runtime classpath as the dependency has been selected in 
compile scope. As such the example is consistent in test and runtime.
{code:java}
[INFO] --- dependency:3.6.0:tree (default-cli) @ acme-product-a ---
[INFO] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[INFO] +- org.acme:acme-lib-d:jar:1.0.0-SNAPSHOT:test
[INFO] |  \- org.acme:acme-lib-c:jar:2.0.0-SNAPSHOT:compile
[INFO] \- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile{code}
{code:java}
# mvn -f product-a dependency:tree -Dverbose=true
...
[INFO] --- dependency:3.6.0:tree (default-cli) @ acme-product-a ---
[INFO] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[INFO] +- org.acme:acme-lib-d:jar:1.0.0-SNAPSHOT:test
[INFO] |  \- org.acme:acme-lib-c:jar:2.0.0-SNAPSHOT:compile
[INFO] \- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile
[INFO]    \- (org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:compile - omitted for 
conflict with 2.0.0-SNAPSHOT)



# mvn -f product-a org.basepom.maven:dependency-scope-maven-plugin:1.0.1:check
...
[INFO] --- dependency-scope:1.0.1:check (default-cli) @ acme-product-a ---
[INFO] No test dependency scope issues found{code}
 

By adding the following patch in the pom.xml of product-a
{code:java}
--- a/product-a/pom.xml
+++ b/product-a/pom.xml
@@ -20,6 +20,12 @@
       <artifactId>acme-lib-b</artifactId>
       <version>1.0.0-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.acme</groupId>
+      <artifactId>acme-lib-c</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>{code}
The dependency acme-lib-c is now selected with scope test and will not be 
present at runtime and leads to CNFEx at runtime for any code of acme-lib-b 
that depends on those. However everything will be fine during testing.
{code:java}
[INFO] --- dependency:3.6.0:tree (default-cli) @ acme-product-a ---
[INFO] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[INFO] +- org.acme:acme-lib-d:jar:1.0.0-SNAPSHOT:test
[INFO] +- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile
[INFO] \- org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:test
{code}
{code:java}
# mvn -f product-a dependency:tree -Dverbose=true
....
[INFO] --- dependency:3.6.0:tree (default-cli) @ acme-product-a ---
[INFO] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[INFO] +- org.acme:acme-lib-d:jar:1.0.0-SNAPSHOT:test
[INFO] |  \- (org.acme:acme-lib-c:jar:2.0.0-SNAPSHOT:test - omitted for 
conflict with 1.0.0-SNAPSHOT)
[INFO] +- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile
[INFO] |  \- (org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:compile - omitted for 
duplicate)
[INFO] \- org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:test (scope not updated to 
compile)

# mvn -f product-a  org.basepom.maven:dependency-scope-maven-plugin:1.0.1:check
...
[INFO] --- dependency-scope:1.0.1:check (default-cli) @ acme-product-a ---
[WARNING] Found a problem with test-scoped dependency org.acme:acme-lib-c
[WARNING] Scope compile was expected by artifact 
org.acme:acme-lib-b:1.0.0-SNAPSHOT
[WARNING]
[WARNING] Dependency chain:
[WARNING] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[WARNING] \- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile
[WARNING]    \- org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:compile{code}
 

 


was (Author: JIRAUSER301820):
In the current state of your example, for dependency acme-lib-c the issues that 
might arise from difference between 1.0.0 and 2.0.0 version selection will be 
similar in test and runtime classpath as the dependency has been selected in 
compile scope. As such the example is consistent in test and runtime.
{code:java}
[INFO] --- dependency:3.6.0:tree (default-cli) @ acme-product-a ---
[INFO] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[INFO] +- org.acme:acme-lib-d:jar:1.0.0-SNAPSHOT:test
[INFO] |  \- org.acme:acme-lib-c:jar:2.0.0-SNAPSHOT:compile
[INFO] \- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile{code}
{code:java}
# mvn -f product-a dependency:tree -Dverbose=true
...
[INFO] --- dependency:3.6.0:tree (default-cli) @ acme-product-a ---
[INFO] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[INFO] +- org.acme:acme-lib-d:jar:1.0.0-SNAPSHOT:test
[INFO] |  \- org.acme:acme-lib-c:jar:2.0.0-SNAPSHOT:compile
[INFO] \- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile
[INFO]    \- (org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:compile - omitted for 
conflict with 2.0.0-SNAPSHOT)



# mvn org.basepom.maven:dependency-scope-maven-plugin:1.0.1:check
...
[INFO] --- dependency-scope:1.0.1:check (default-cli) @ acme-product-a ---
[INFO] No test dependency scope issues found{code}
 

By adding the following patch in the pom.xml of product-a
{code:java}
--- a/product-a/pom.xml
+++ b/product-a/pom.xml
@@ -20,6 +20,12 @@
       <artifactId>acme-lib-b</artifactId>
       <version>1.0.0-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.acme</groupId>
+      <artifactId>acme-lib-c</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>{code}
The dependency acme-lib-c is now selected with scope test and will not be 
present at runtime and leads to CNFEx at runtime for any code of acme-lib-b 
that depends on those. However everything will be fine during testing.
{code:java}
[INFO] --- dependency:3.6.0:tree (default-cli) @ acme-product-a ---
[INFO] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[INFO] +- org.acme:acme-lib-d:jar:1.0.0-SNAPSHOT:test
[INFO] +- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile
[INFO] \- org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:test
{code}
{code:java}
# mvn -f product-a dependency:tree -Dverbose=true
....
[INFO] --- dependency:3.6.0:tree (default-cli) @ acme-product-a ---
[INFO] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[INFO] +- org.acme:acme-lib-d:jar:1.0.0-SNAPSHOT:test
[INFO] |  \- (org.acme:acme-lib-c:jar:2.0.0-SNAPSHOT:test - omitted for 
conflict with 1.0.0-SNAPSHOT)
[INFO] +- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile
[INFO] |  \- (org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:compile - omitted for 
duplicate)
[INFO] \- org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:test (scope not updated to 
compile)

# mvn org.basepom.maven:dependency-scope-maven-plugin:1.0.1:check
...
[INFO] --- dependency-scope:1.0.1:check (default-cli) @ acme-product-a ---
[WARNING] Found a problem with test-scoped dependency org.acme:acme-lib-c
[WARNING] Scope compile was expected by artifact 
org.acme:acme-lib-b:1.0.0-SNAPSHOT
[WARNING]
[WARNING] Dependency chain:
[WARNING] org.acme:acme-product-a:jar:1.0.0-SNAPSHOT
[WARNING] \- org.acme:acme-lib-b:jar:1.0.0-SNAPSHOT:compile
[WARNING]    \- org.acme:acme-lib-c:jar:1.0.0-SNAPSHOT:compile{code}
 

 

> Scope mediation improvements
> ----------------------------
>
>                 Key: MRESOLVER-391
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-391
>             Project: Maven Resolver
>          Issue Type: Bug
>          Components: Resolver
>            Reporter: Tamas Cservenak
>            Priority: Major
>             Fix For: 2.0.0
>
>
> As per MNG-5988: if an artifact in "test" scope is found nearer, but in scope 
> "compile" is found deeper in graph, the "test" scope wins. This at runtime 
> may lead to CNFEx.



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

Reply via email to