Local dependencies in Leiningen without creating a Maven repo?
Asked Answered
P

2

9

I'm building a Compojure web application, and I'd like it to use functions from another Clojure project I wrote. I'm not at all familiar with Maven, and from what I've heard, it has a very steep learning curve. Unfortunately, everything I've seen suggests using a private Maven repo as a dependency and doesn't suggest an alternative. I'd really like to avoid struggling with Maven if possible. Does anyone know of an alternative? I'm currently using the latest version of Leiningen.

Patrinapatriot answered 5/8, 2014 at 18:6 Comment(0)
L
17

If the other project is also a lein project, you just need to do a "lein install" and that will take care of creating all the local maven repo stuff. Then you can just depend on that project as you would do with any other lib. For example:

 (defproject mylib "1.0"
      ....)

  lein install

  (defproject myotherproject "a.b.c"
     :dependencies [[mylib "1.0"]]
     .....)

If you are sharing "myotherproject" with other people and you want to remove some of the inconvenience of doing a "lein install" every time you change the mylib project, have a look at the lein checkouts feature and then use the equivalent of svn externals of your VCS of choice.

Laughing answered 5/8, 2014 at 23:15 Comment(3)
My pleasure. Could you please accept the answer given that it works?Laughing
sorry! new to the site. just did.Patrinapatriot
I don't understand how just lein installing will find the local repo I'm trying to include. Is there something I'm missing?Lx
S
0

'lein checkout' appears to be another way to achieve the same goal. a lot more details here and here. In general, the idea is to create a symlink to the local copy of the dependency, but the process does require one lein install. I also found this lein plugin that might be even better, but I've yet to try it myself.

Selfeffacing answered 18/5, 2022 at 19:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.