0

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
vallllll
  • 2,731
  • 6
  • 43
  • 77
  • Where does that jar come from? are you building it in another maven/lein project? If so you can use "mvn install" to make it available locally. The suggestions at the pgrs site should be stable for checking into your version control with your project. So others won't have to do much. Assuming you're distributing source code. – DrLivingston Apr 01 '14 at 18:08
  • I don't use maven I use ant for the java project but this jar is already included as jar in the top project, it is not being compiled each time. So I have the buildbot scripts that call ant and then calls the lein uberjar. – vallllll Apr 01 '14 at 18:52
  • 1
    Then it really sounds like you just want the pgrs solution. You're worried about someone having to do something every time they clone the project, but if you check the jar in and set it up like they suggest they shouldn't have to do anything. – DrLivingston Apr 01 '14 at 19:36

1 Answers1

0

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

vallllll
  • 2,731
  • 6
  • 43
  • 77