I am starting lein new
project in clojure and want to use the goose article extraction library. Unfortunately I couldn't find the jar of that library on any publicly available maven repository, so I set out to add it to a local maven repository.
In the project directory, I copied the goose jar and its pom.xml
files and did
mkdir maven-repo
mvn install:install-file -Dfile=goose-2.1.6.jar -DartifactId=goose -Dversion=2.1.6 \
-DgroupId=local -Dpackaging=jar -DlocalRepositoryPath=maven-repo -DpomFile=pom.xml
And added the following to project.clj
:repositories {"local" ~(str (.toURI (java.io.File. "maven-repo")))}
and [local/goose "2.1.6"]
in :dependencies
. Now when I do a lein deps
, I get the goose-2.1.6.jar file added to lib directory, but not the dependencies of goose. They are listed in the goose's pom.xml
file.
Is there a way I can fix this other than listing goose's dependencies in my project.clj
?
Maven searches for the dependencies in the following order: Local repository then Central repository then Remote repository. If dependency is not found in these repositories, maven stops processing and throws an error.
When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository. It helps to avoid references to dependencies stored on remote machine every time a project is build. Maven local repository by default get created by Maven in %USER_HOME% directory.
The Local Repository Maven's local repository is a directory on the local machine that stores all the project artifacts. When we execute a Maven build, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named . m2.
You can use lein-localrepo instead of the lengthy mvn command: https://github.com/kumarshantanu/lein-localrepo
Install like this:
lein localrepo coords target/goose-2.1.6.jar | xargs lein localrepo install
However, that alone will not help to install the POM file in the repo. You should additionally run this:
cp pom.xml ~/.m2/repository/goose/goose/2.1.6/goose-2.1.6.pom
Note that in this example Goose will be installed as groupId=goose
, artifactId=goose
. You can override that if you wish, and probably you should.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With