Welcome! Please see the About page for a little more info on how this works.

0 votes
in Tools by

The Clojure tools.deps resolves remote Maven repositories, and generally obeys the Maven settings.xml. Unfortunately, in the following settings example, it will not pickup the authentication for the mirror. According to Maven convention, the mirror's Id should be used to determine the server settings, in this case "planetmirror.com"

<settings>
    <servers>
        <server>
            <id>planetmirror.com</id>
            <username>my_login</username>
            <password>my_password</password>
            <configuration></configuration>
        </server>
    </servers>
    <mirrors>
        <mirror>
            <id>planetmirror.com</id>
            <name>PlanetMirror Australia</name>
            <url>http://downloads.planetmirror.com/pub/maven2</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
</settings>

The reason is that the code in tools.alpha.util.maven.clj uses the repository name to find the server-settings:

The following patch fixes the issue:

modified   src/main/clojure/clojure/tools/deps/alpha/util/maven.clj
@@ -77,7 +77,7 @@
   (let [mirrors (.getMirrors settings)
         selector (DefaultMirrorSelector.)]
     (run! (fn [^Mirror mirror] (.add selector
-                                 (.getName mirror)
+                                 (.getId mirror)
                                  (.getUrl mirror)
                                  (.getLayout mirror)
                                  false
@@ -110,7 +110,8 @@
         maybe-repo (.build builder)
         mirror (select-mirror settings maybe-repo)
         proxy (select-proxy settings (or mirror maybe-repo))
-        ^Server server-setting (->> (.getServers settings) (filter #(= name (.getId ^Server %))) first)    ]
+        server-id (-> (or mirror maybe-repo) (.getId))
+        ^Server server-setting (->> (.getServers settings) (filter #(= server-id (.getId ^Server %))) f    irst)]
     (->
       (cond-> builder
         mirror (.setUrl (.getUrl mirror))

1 Answer

+1 vote
by
selected by
 
Best answer

Logged as https://clojure.atlassian.net/browse/TDEPS-177, thanks for the report. I will try to get that fixed soon.

...