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

Tamas Cservenak commented on MNG-6357:
--------------------------------------

The PR with [~suztomo] reproducer:
{noformat}
[cstamas@urnebes main (master %)]$ mvn -V 
-Daether.system.resolveDependencies.visitor=preOrder -q exec:exec 
-Dexec.executable=echo -Dexec.args="%classpath"
Apache Maven 3.9.5-SNAPSHOT (bf3261cc66fd653ed3457153b2bfbe9bbc7d5d7b)
Maven home: /home/cstamas/.sdkman/candidates/maven/3.9.5-SNAPSHOT
Java version: 17.0.8, vendor: Eclipse Adoptium, runtime: 
/home/cstamas/.sdkman/candidates/java/17.0.8-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.4.6-200.fc38.x86_64", arch: "amd64", family: 
"unix"
/home/cstamas/tmp/MNG-6357/triangle-linkage-error/main/target/classes:/home/cstamas/.m2/repository-oss/suztomo/artifact1/0.0.1-SNAPSHOT/artifact1-0.0.1-SNAPSHOT.jar:/home/cstamas/.m2/repository-oss/suztomo/artifact4/0.0.1-SNAPSHOT/artifact4-0.0.1-SNAPSHOT.jar:/home/cstamas/.m2/repository-oss/suztomo/artifact2/0.0.1-SNAPSHOT/artifact2-0.0.1-SNAPSHOT.jar:/home/cstamas/.m2/repository-oss/suztomo/artifact5/0.0.1-SNAPSHOT/artifact5-0.0.1-SNAPSHOT.jar:/home/cstamas/.m2/repository-oss/suztomo/artifact3/0.0.1-SNAPSHOT/artifact3-0.0.1-SNAPSHOT.jar
[cstamas@urnebes main (master %)]$ mvn -V 
-Daether.system.resolveDependencies.visitor=levelOrder -q exec:exec 
-Dexec.executable=echo -Dexec.args="%classpath"
Apache Maven 3.9.5-SNAPSHOT (bf3261cc66fd653ed3457153b2bfbe9bbc7d5d7b)
Maven home: /home/cstamas/.sdkman/candidates/maven/3.9.5-SNAPSHOT
Java version: 17.0.8, vendor: Eclipse Adoptium, runtime: 
/home/cstamas/.sdkman/candidates/java/17.0.8-tem
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.4.6-200.fc38.x86_64", arch: "amd64", family: 
"unix"
/home/cstamas/tmp/MNG-6357/triangle-linkage-error/main/target/classes:/home/cstamas/.m2/repository-oss/suztomo/artifact1/0.0.1-SNAPSHOT/artifact1-0.0.1-SNAPSHOT.jar:/home/cstamas/.m2/repository-oss/suztomo/artifact2/0.0.1-SNAPSHOT/artifact2-0.0.1-SNAPSHOT.jar:/home/cstamas/.m2/repository-oss/suztomo/artifact3/0.0.1-SNAPSHOT/artifact3-0.0.1-SNAPSHOT.jar:/home/cstamas/.m2/repository-oss/suztomo/artifact4/0.0.1-SNAPSHOT/artifact4-0.0.1-SNAPSHOT.jar:/home/cstamas/.m2/repository-oss/suztomo/artifact5/0.0.1-SNAPSHOT/artifact5-0.0.1-SNAPSHOT.jar
[cstamas@urnebes main (master %)]$ 
{noformat}

> Dependency order should be nearest first 
> -----------------------------------------
>
>                 Key: MNG-6357
>                 URL: https://issues.apache.org/jira/browse/MNG-6357
>             Project: Maven
>          Issue Type: Improvement
>            Reporter: Robert Scholte
>            Priority: Major
>             Fix For: 4.0.x-candidate
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> In case of version conflicts, the nearest wins. However, the dependency order 
> is simply based on tree walking. In the rare that a transitive dependency of 
> the first direct dependency contains the same class as a latter direct 
> dependency, the code is compiled against the first one, which is odd.
> It would make more sense if direct dependencies are the first ones on the 
> classpath, followed by the first level transitive dependencies, etc. This 
> will make the explanation equal to version conflict resolution: nearest wins.
> I don't expect real issues due to this change, otherwise we would have had 
> this issue much earlier. This should become the new default order, however 
> there should be a system property to get the original order, just in case 
> somebody needs it.
>  
> Current workaround: make the critical dependency the first direct dependency.



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

Reply via email to