我试图增强使用lein构建的Clojure/ClojureScript项目的依赖性管理。因此,我使用一个名为莱茵-工具.戴普的库。我将它添加到我的project.clj文件中:
(defproject my-project
:description "description"
:url "https://github.com/pdelfino/whatever-does-the-repos-name-matter-at-all-here?"
:plugins [[lein-tools-deps "0.4.5"]]
...omitted...)这个添加的主要目的是直接从GitHub包获得私有maven包,而不是让它们在本地运行,并为每个新版本执行lein install。
此外,我还创建了一个deps.edn文件。它适用于public packages。但是,我在private上遇到了麻烦。我正试着跟随文档。因此,我试着:
{:paths ["src" "dev"]
:deps { ;; lein dependencies
org.clojure/clojure {:mvn/version "1.9.0"}
org.clojure/clojurescript {:mvn/version "1.10.339"}
org.clojure/tools.nrepl {:mvn/version "RELEASE"}
;; private
com.my-organization/private-repo1 {:mvn/version "1.2.15"
:deps/manifest :pom
:git/url "https://github.com/my-org/private-repo"}
com.my-organization/private-repo2 {:sha "230483c88ff1cef5248878182ec98cff07b212a9"
;:git/tag "v1.2.15"
:git/url "git@github.com:my-org/private-repo.git"}}
:mvn/repos {"github" {:url "https://maven.pkg.github.com/my_organization/*"}
;; "github-2" {:url "https://github.com/my_organization/*"}}}私有包作为私有包托管在GitHub包上:
有一个XML保存元数据:
<dependency>
<groupId>com.my-organization</groupId>
<artifactId>private-repo1</artifactId>
<version>1.2.15</version>
</dependency>此外,我还有一个.m2/settings.xml文件:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<offline/>
<pluginGroups/>
<servers>
<!-- <server> -->
<!-- <id>github-2</id> -->
<!-- <username>pdelfino</username> -->
<!-- <password>my-password-which-will-not-be-shared</password> -->
<!-- <configuration> -->
<!-- <httpHeaders> -->
<!-- <property> -->
<!-- <name>Authorization</name> -->
<!-- <!-\- Base64-encoded "<username>:<password>" -\-> -->
<!-- <value>Basic password-which-will-not-be-shared==</value> -->
<!-- </property> -->
<!-- </httpHeaders> -->
<!-- </configuration> -->
<!-- </server> -->
<server>
<id>github</id>
<username>pdelfino</username>
<password>password-which-will-not-be-shared</password>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<!-- Base64-encoded "<username>:<password>" -->
<value>Basic converted-password-which-will-not-be-shared==</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>不幸的是,当我在这个存储库上执行lein install时,我的期望是这些包将被成功安装。
但是,终端返回一个错误:
➜ lein install
If there are a lot of uncached dependencies this might take a while ...
Cloning: git@github.com:my-organization/private-repo1.git
org.eclipse.jgit.api.errors.TransportException: git@github.com:my-organization/private-repo1.git: Auth fail我该怎么解决这个问题?
发布于 2022-10-21 14:17:45
我解决了问题。但是,我并不完全理解我自己的解决办法。
首先,我保留了.m2/settings.xml。但不再持有我的凭据了:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username></username>
<password></password>
</server>
</servers>
</settings>此外,在project.clj上,我添加了:
:repositories {"releases" {:url "https://maven.pkg.github.com/tallyfor/*"
:username "pdelfino"
:password :env}}注意,:password有一个指针:env,它引用了我通过.zshrc版本配置的环境。
export LEIN_PASSWORD="my-personal-access-github-token-which-will-not-be-shared"请注意,字符串"my-personal-access-github-token-which-will-not-be-shared“与我的.npmrc文件中用于安装私有npm包的字符串相同,这些包在GitHub上免费托管。
我不明白的一点是,为什么需要保留.m2/settings.xml,即使它有而不是有任何内容。
如果我在.m2/settings.xml上评论内容
<!-- <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" -->
<!-- xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> -->
<!-- <servers> -->
<!-- <server> -->
<!-- <id>github</id> -->
<!-- <username></username> -->
<!-- <password></password> -->
<!-- </server> -->
<!-- </servers> -->
<!-- </settings> -->如果我再次尝试执行lein install,它将不起作用:
➜ LEIN_SNAPSHOTS_IN_RELEASE=true lein install
If there are a lot of uncached dependencies this might take a while ...
java.io.IOException: 1 problem was encountered while building the effective settings
[FATAL] Non-readable settings /Users/pedro/.m2/settings.xml: no more data available START_DOCUMENT seen ...<!-- </settings> -->\n... @11:1 @ /Users/pedro/.m2/settings.xml发布于 2022-10-19 11:13:39
我不明白你为什么需要这个插件。只要您可以从运行构建的机器(否则是ssh-agent)通过SSH访问存储库,就可以使用ssh链接将依赖项添加到deps.edn:
com.my-organization/private-repo1
{:git/url "ssh://git@github.com:/my-org/private-repo.git"
:sha "230483c88ff1cef5248878182ec98cff07b212a9"}https://stackoverflow.com/questions/74115124
复制相似问题