Clojure: using a local Maven repository in Leiningen based projects
I had what must be a common problem so I am documenting the solution here using this reference. I have an IntelliJ mixed project with both Java and Clojure code. I wanted to reuse this project in a small Clojure/Compojure web application that uses Leiningen. I added a new target jar_to_local_mvn to the Makefile in my IntelliJ project directory that takes a JAR file in the IntelliJ project directory and adds it to my local Maven repository (the Makefile target for the dependency target jar is not shown):
jar_to_local_mvn: jar mvn install:install-file -Dfile=knowledgebooks-0.2.0.jar -DgroupId=self \ -DartifactId=knowledgebooks -Dversion=0.2.0 \ -Dpackaging=jar -DgeneratePom=true
Then in my Clojure/Compojure web application project directory I added a local dependency to my project.clj file:
Now, when I get all project dependencies it also copies my JAR file in addition to dependencies copied from Clojars (JARs retrieved from Clojars are not shown):
$ lein deps [copy] Copying 1 file to /Users/mark/Coding/Clojure/KBSportal/lib
The code in the IntelliJ project is very stable and is unlikely to change frequently so having to manually re-run the Makefile is not a nuisance.