Clojure 工具 .deps 解析远程 Maven 存储库,并通常遵循 Maven 的 settings.xml 配置。遗憾的是,在以下设置示例中,它将无法收集镜像的认证信息。根据 Maven 习惯,应使用镜像的 ID 确定服务器设置,在本例中为 "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>
原因是 tools.alpha.util.maven.clj 中的代码使用 名称 来查找服务器设置
以下补丁修复了此问题
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))