<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged tools.deps maven mirror authentication</title>
<link>https://ask.clojure.org/index.php/tag/tools.deps+maven+mirror+authentication</link>
<description></description>
<item>
<title>Support maven mirror with authentication</title>
<link>https://ask.clojure.org/index.php/10416/support-maven-mirror-with-authentication</link>
<description>&lt;p&gt;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 &quot;planetmirror.com&quot;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;settings&amp;gt;
    &amp;lt;servers&amp;gt;
        &amp;lt;server&amp;gt;
            &amp;lt;id&amp;gt;planetmirror.com&amp;lt;/id&amp;gt;
            &amp;lt;username&amp;gt;my_login&amp;lt;/username&amp;gt;
            &amp;lt;password&amp;gt;my_password&amp;lt;/password&amp;gt;
            &amp;lt;configuration&amp;gt;&amp;lt;/configuration&amp;gt;
        &amp;lt;/server&amp;gt;
    &amp;lt;/servers&amp;gt;
    &amp;lt;mirrors&amp;gt;
        &amp;lt;mirror&amp;gt;
            &amp;lt;id&amp;gt;planetmirror.com&amp;lt;/id&amp;gt;
            &amp;lt;name&amp;gt;PlanetMirror Australia&amp;lt;/name&amp;gt;
            &amp;lt;url&amp;gt;http://downloads.planetmirror.com/pub/maven2&amp;lt;/url&amp;gt;
            &amp;lt;mirrorOf&amp;gt;central&amp;lt;/mirrorOf&amp;gt;
        &amp;lt;/mirror&amp;gt;
    &amp;lt;/mirrors&amp;gt;
&amp;lt;/settings&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The reason is that the code in tools.alpha.util.maven.clj uses the repository &lt;strong&gt;name&lt;/strong&gt; to find the server-settings:&lt;/p&gt;
&lt;p&gt;The following patch fixes the issue:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;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 (-&amp;gt;&amp;gt; (.getServers settings) (filter #(= name (.getId ^Server %))) first)    ]
+        server-id (-&amp;gt; (or mirror maybe-repo) (.getId))
+        ^Server server-setting (-&amp;gt;&amp;gt; (.getServers settings) (filter #(= server-id (.getId ^Server %))) f    irst)]
     (-&amp;gt;
       (cond-&amp;gt; builder
         mirror (.setUrl (.getUrl mirror))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Tools</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10416/support-maven-mirror-with-authentication</guid>
<pubDate>Wed, 07 Apr 2021 22:48:13 +0000</pubDate>
</item>
</channel>
</rss>