Fork me on GitHub
#leiningen
<
2024-03-13
>
Omer ZAK09:03:53

This is probably a FAQ, but Google search did not find me the answer I need. I have a leiningen project which depends upon few libraries, which are fetched from Maven Central and Clojars. However, I want to patch one of the libraries and depend upon the patched version of the library. I successfully rebuilt the library after patching it and I have its jar file locally. I want my project.clj to declare dependency upon the local jar file rather than upon the Maven Central/Clojars version. How to specify this in the :dependencies clause in project.clj? Thanks!

vemv09:03:38

Simplest thing would be to release your jar in Clojars, depend on it, and apply :exclusions so that the original jar won't be depended on Use lein deps :tree to confirm that the original is zapped Hope it helps!

Omer ZAK10:03:02

For me it is not the simplest thing to do. Requires me to expose half-baked buggy code to the world. The most obvious thing to do is to have a way to depend upon a local jar, and this is what I am looking for.

Omer ZAK10:03:00

I found https://clojure.org/reference/deps_edn It specifies the following format for deps.edn:

;; Local jar
   localjar/name {:local/root "path/to.jar"
                  :exclusions [lib1 lib2]}}
I tried to translate it into Leiningen format as follows: [target/name {:local/root "/path/to/target/name-0.11.1-beta-standalone.jar"}] and got the following error message from lein deps: java.lang.IllegalArgumentException: Bad artifact coordinates target:name:jar:{:local/root "/path/to/target/name-0.11.1-beta-standalone.jar"}, expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version> (there may be inaccuracies, because I censored the real names) It is not clear to me how to write the expected format in my case.

vemv11:03:23

You can also add the .jar to :resources

Alex Miller (Clojure team)12:03:08

If you locally install your modified project, you can depend on it as a normal maven dep

Alex Miller (Clojure team)12:03:34

Lein doesn’t support local jars like deps

Alex Miller (Clojure team)12:03:56

How to do that depends on the other projects build - mvn install or lein install should do this for you

vemv12:03:02

> Lein doesn’t support local jars like deps Not as a first-class feature, but adding a .jar to :resources works Local install is also OK, perhaps a little less reproducible (you'd have to make sure to do the same locally and in CI prior to test running, deployments, etc)