install JAR from remote repo (clojar)

2020-07-09 10:39发布

问题:

I want to download and install this Clojure library but cannot for the life of me figure it out. I researched Maven, but couldn't get it to find the repo. How can I easily install a Clojure library onto my machine?

回答1:

download https://clojars.org/repo/clj-http/clj-http/0.4.1/clj-http-0.4.1.jar

mvn install:install-file -DgroupId=clj-http -DartifactId=clj-http -Dversion=0.4.1 -Dpackaging=jar -Dfile=clj-http-0.4.1.jar


回答2:

You could add the repository containing this jar to your pom or settings file and specify the relevant jar as a dependency.

<repository>
  <id>clojars.org</id>
  <url>http://clojars.org/repo</url>
</repository>
...
<dependency>
   <groupId>clj-http</groupId>
   <artifactId>clj-http</artifactId>
   <version>0.4.1</version>
</dependency>


回答3:

If you are using Leiningen you can just read all about how to connect to repository server on a recent Sonatype blog post from Tim O'Brien.

If you are using Maven you should get a repo server like Nexus and setup the clojure repo as another proxy repository and add it to your public group.

If neither of these approaches is ok with you you can use Raghurams approach or number23_cn. Both of them however are semi optimal and will not scale for teams or many artifacts..