Leiningen: how to eliminate dependencies with uberjaring?

When using leiningen to build Clojure applications, how can certain dependencies be excluded from inclusion in the JAR file when using lein uberjar ?

+5
source share
2 answers

Use the provided element for the leiningen profile.

  :profiles {:dev {:dependencies [[ring-mock "0.1.5"] [prismatic/dommy "0.1.3"] [org.bouncycastle/bcprov-jdk15on "1.50"]]} :provided {:dependencies [[org.bouncycastle/bcprov-jdk15on "1.50"]]}} 

One common use case is a bouncycastle , which should be excluded from the signed JAR and provided externally using its own jar file at runtime.

+4
source

Similar to what Guillermo suggested changing in your project: profiles to include something like:

 :provided {:dependencies [[org.bouncycastle/bcprov-jdk15on "1.50"] [org.bouncycastle/bcpg-jdk15on "1.50"]]} 

(Specific versions may vary.)

The problem is that if you use the Clojure shell library (e.g. clj-pgp or thi.ng/crypto ), this forces jar to be included in uberjar, disrupting the process.

My solution was to fork the library and put it in clojars after changing its project.clj to use the provided dependencies.

More details here: http://side-effects-bang.blogspot.com/2015/02/deploying-uberjars-that-use-bouncy.html

+3
source

Source: https://habr.com/ru/post/1208031/


All Articles