technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.6k forks source link

Relocated dependencies don't show up in `lein deps :tree` #2745

Open plexus opened 3 years ago

plexus commented 3 years ago

Initial debugging steps

Describe the bug

Maven has a feature called "relocation" where a pom for a given artifact can signal that this artifact has relocated to a different groupId. This acts as kind of redirect, for instance if you depend on org.hibernate/hibernate-validator, then this will actually end up using org.hibernate.validator/hibernate-validator, because of this stanza in the pom.xml:

    <distributionManagement>
        <relocation>
            <groupId>org.hibernate.validator</groupId>
        </relocation>
    </distributionManagement>

This in itself works fine, the new artifact will be downloaded and added to the classpath, but it will not get listed when calling lein deps :tree.

To Reproduce Steps to reproduce the behavior:

project.clj:

(defproject relocation-test "0.1.0-SNAPSHOT"
  :dependencies [[org.hibernate/hibernate-validator "7.0.1.Final"]])

and invoke lein deps :tree

result:

Actual behavior

$ lein deps :tree
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [nrepl "0.8.3" :exclusions [[org.clojure/clojure]]]

Side note, I have verified with clojure.java.classpath that hibernate-validator is indeed on the classpath:

/home/arne/.m2/repository/org/hibernate/validator/hibernate-validator/7.0.1.Final/hibernate-validator-7.0
.1.Final.jar

Expected behavior

$ lein deps :tree
 [clojure-complete "0.2.5" :exclusions [[org.clojure/clojure]]]
 [nrepl "0.8.3" :exclusions [[org.clojure/clojure]]]
 [org.hibernate.validator/hibernate-validator "7.0.1.Final"]

Environment

Additional context

This is prompted by https://github.com/clojars/clojars-web/issues/801 and https://github.com/lambdaisland/open-source/issues/2. Due to the new Clojars policies around group id naming there is some interest in Maven's relocation support, and we are looking at what the support is across tools.

technomancy commented 2 years ago

Happy to take a patch for this.