Use Leiningen With Local M2 Repository
Asked Answered
E

1

13

I want to compile a local jar into my clojure project, I can do this easily with the following

https://gist.github.com/stuartsierra/3062743

mkdir repo
mvn install:install-file -DgroupId=local -DartifactId=bar \
    -Dversion=1.0.0 -Dpackaging=jar -Dfile=bar.jar \
    -DlocalRepositoryPath=repo

But I have a continuous integration and build server (jenkins) that looks in ~/.m2. How can I get leiningen to look in .m2???

Echovirus answered 11/6, 2013 at 2:8 Comment(3)
What errors are you getting? It should already be looking in ~/.m2 by default.Loireatlantique
I was getting the Exception in thread "main" java.io.FileNotFoundException: Could not locate myapp/module__init.class or myapp/module.clj on classpath.Echovirus
I tried installing my project in .m2 with "lein pom" and then "mvn install", which did copy the jars to ~/.m2 but the build still failed. So eventually what I did was force the sibling libraries to be built in local_mvn_repo following nakkaya.com/2010/03/16/… Basically using building projects together is something im still nto totally sure I understand with Leiningen. When to use the "nakkaya" trick, and when how to use ~/.m2. Still fuzzy!Echovirus
D
10

Based on the documentation, it looks like the key you're after is :local-repo in project.clj. Since you want to have different local repository locations on different servers, I would put this in a profile as opposed to directly in the project.clj.

Probably the best approach would be to create a :user profile in ~/.lein/profiles.clj on whichever machine you want to change the location of the local repository:

{:user {:local-repo "repo"}}
Desiccant answered 11/6, 2013 at 12:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.