I am trying to enhance the dependency management of a Clojure/ClojureScript project built with lein
. Hence, I am using a library called lein-tools-deps. I added it to my project.clj
file:
(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...)
The main purpose of this addition is getting private maven packages directly from GitHub Packages instead of having them locally and doing lein install
for every new release.
Also, I created a deps.edn
file. It works for the public packages
. But, I am having trouble with the private
ones. I am trying to follow the documentation. Hence, I tried:
{: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 "[email protected]:my-org/private-repo.git"}}
:mvn/repos {"github" {:url "https://maven.pkg.github.com/my_organization/*"}
;; "github-2" {:url "https://github.com/my_organization/*"}}}
The private packages are being hosted on GitHub Packages as private packages:
There is a XML holding meta-data:
<dependency>
<groupId>com.my-organization</groupId>
<artifactId>private-repo1</artifactId>
<version>1.2.15</version>
</dependency>
In addition, I have a .m2/settings.xml
file:
<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>
Unfortunately, when I execute lein install
on this repository, my
expectation was that the packages would be successfully installed.
But, terminal returns an error:
➜ lein install
If there are a lot of uncached dependencies this might take a while ...
Cloning: [email protected]:my-organization/private-repo1.git
org.eclipse.jgit.api.errors.TransportException: [email protected]:my-organization/private-repo1.git: Auth fail
How do I fix this?
CodePudding user response:
I don't see why you need the plugin. As long as you can access the repository via SSH from the machine where you are running the build on (otherwise configure ssh-agent
), you can add the dependency to deps.edn
with the ssh
link:
com.my-organization/private-repo1
{:git/url "ssh://[email protected]:/my-org/private-repo.git"
:sha "230483c88ff1cef5248878182ec98cff07b212a9"}
CodePudding user response:
I solved the problem. But, I do not fully understand my own solution.
First, I kept the .m2/settings.xml
. But it does not hold my
credentials anymore:
<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>
Also, on project.clj
I added:
:repositories {"releases" {:url "https://maven.pkg.github.com/tallyfor/*"
:username "pdelfino"
:password :env}}
Note that the :password
has a pointer :env
making a reference to
the environment which I have configured via an edition of .zshrc
:
export LEIN_PASSWORD="my-personal-access-github-token-which-will-not-be-shared"
Note that the string
"my-personal-access-github-token-which-will-not-be-shared" is the same
I have on my .npmrc
file to install private npm packages being
hosted for free on GitHub.
One of the points that I do not understand is why a need to keep the
.m2/settings.xml
even though it does not have any content.
If I comment out the content on .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> -->
And if I try to execute lein install
again, it does not work:
➜ 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