Question

I have project on my git repo and one of the jars that it uses, is actually inside the git repository. Here is the structure

project /lib/mylib.jar /clojure_project/project.clj

I need to add mylib.jar as dependecy but not to have any maven repos just local or git or some kind of straightforward way like in java/android... I am not experienced with clojure.

I have tried many options: Use maven local repo as suggested here: https://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/ Problem is each time somebody clones the project they have to readd the maven repo plus download a bunch of maven staff.

Then there is the git approach here: clojure and leiningen - using a git repository as dependency but it didn't work for me also I don't want to install any progins. Is there another way to add jars to clojure project?

Was it helpful?

Solution

At the end after examining the pgrs link I went to the guys own project and examined the project.clj

Turns out the repo has to be called local:

:repositories {"local" "file:repo"}

then you have to add the dependency:

:dependencies [[org.clojure/clojure "1.4.0"]
             [org.clojure/tools.cli "0.2.2"]
             [org.clojure/java.jdbc "0.2.3"]
             [mylib "0.1"]]

In the buildscript here is what I have:

mkdir repo
FILE_NAME=`ls -c ../path/to/mylib-* | head -n 1`
mvn install:install-file -Dfile=$FILE_NAME -DartifactId=mylib -Dversion=0.1 -DgroupId=mylib -Dpackaging=jar -DlocalRepositoryPath=repo  -DcreateChecksum=true

This works on my Ubuntu 12.04 machine with java 7 (oracle) and Leiningen 1.7.1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top