Fork me on GitHub
#depstar
<
2020-09-23
>
timo09:09:59

Hi 👋

timo09:09:07

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?

practicalli-johnny11:09:44

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.

timo12:09:23

alright, good to know. Thank you very much!

timo12:09:48

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

practicalli-johnny12:09:17

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.

seancorfield16:09:46

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

seancorfield16:09:17

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).

seancorfield16:09:06

(! 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.

seancorfield16:09:26

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

seancorfield16:09:23

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)

timo19:09:59

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

timo09:09:50

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