Fork me on GitHub

I am currently setting up CI for a CLJ/CLJS library and CLJS is new to me. The uberjar built is 30MB. Usually I was building and uploading uberjars to clojars. But the project is quite small and shouldn't be 30MB in size. When does one use uberjars and when does one use thinjars?


Short answer: deploy uberjars, publish jars When deploying to a server / container, the uberjar has everything it needs, except for the Java runtime. So its possible to run the uberjar just using a java command (essentially what the Clojure CLI tool wraps). Clojars are a collection of library dependencies, each of which can be added to another project. When adding a library to a project, any dependencies the library contains will be downloaded when running the project. Therefore its is encouraged that libraries have no more dependencies that really needed. Uberjars shouldnt be published to Clojars as this would be very inefficient and a potential cause of dependency conflicts.


alright, good to know. Thank you very much!


lein deploy just did what it did. now I am using depstar and was thinking about this the first time


Yes, I have found using the Clojure CLI tools and the community tools like depstar and clj-new has given me an opportunity for greater understanding.


@U4GEXTNGZ hf.depstar.jar for publishing to Clojars ("thin" JAR), hf.depstar.uberjar for deploying to "production" as an executable ("uber" JAR).


The thing that makes the uberjar so much bigger is the entire Clojure compiler/runtime has to be included (plus any other libraries you depend on).


(! 657)-> clojure -M:new app timo/example
Generating a project called example based on the 'app' template.
(! 658)-> cd example/
(! 659)-> clojure -M:uberjar
Compiling timo.example ...
Building uber jar: example.jar
Processing pom.xml for {timo/example {:mvn/version "0.1.0-SNAPSHOT"}}
(! 660)-> ls -l example.jar 
-rw-------  1 sean  staff  4688835 Sep 23 09:12 example.jar
Essentially "Hello World" is just over 4.5MB with nothing but Clojure itself added.


(! 661)-> java -jar example.jar 
Hello, World!


By contrast, a minimal library project and "thin" JAR:

(! 664)-> clojure -M:new lib timo/example
Generating a project called example based on the 'lib' template.
The lib template is intended for library projects, not applications.
(! 665)-> cd example/
(! 666)-> clojure -M:jar
Building thin jar: example.jar
Processing pom.xml for {timo/example {:mvn/version "0.1.0-SNAPSHOT"}}
(! 667)-> ls -l example.jar 
-rw-------  1 sean  staff  2258 Sep 23 09:30 example.jar
Just 2K for the source of the project itself (and some metadata in the JAR)


now I have a good understanding of it. thanks for the answers!


I mean there supposedly is no AOT-compilation happening as far as I understand it.