Deploy 3rd-party jar to clojars?

2019-06-02 21:47发布

问题:

I'm using a 3rd-party open source Java library with my Clojure project. It's not available in Maven Central or at Clojars. I can create a pom file and figure out how to install it a Maven Central, but--I am lazy and I am used to the increased convenience of Clojure tools such as Leiningen! Is there a convenient way to deploy the 3rd party jar to Clojars? There's no need to build it first; it's already been built. (The Java library uses the tried and true--make.)

If I must give up my laziness, I will, but if not, why bother? (On the other hand, I've already probably spent more time trying this and that, reading Leiningen documentation and blog posts, and asking this question here, than I would have spent if I'd just sat down and made a pom file, etc. I've been unable to find an answer, so far. Laziness is time-consuming!)

回答1:

You have a few options.

First, I wouldn't install a jar for which you don't own the copyright in a public place.

The easiest way to have access to an arbitrary jar via Maven/Leiningen would be to "install" the jar int your local repository. For example, if want your dependency to look like[com.example.foo/bar "1.0.0"], you would install it with the mvn command.

mvn -Dfile=your.jar \
    -DgroupId=com.example.foo \
    -DartifactId=bar \
    -Dversion=1.0.0 \
    -Dpackaging=jar \
    -DgeneratePom=true

This makes the dependency available only to you. If you're on a team, you could require each person to run this command. However, if you don't mind spending a little money, you could host your own repository on S3 using s3-wagon-private.

There's also repository managers like Archiva, Artifactory, and NEXUS.