Uberjar vs Uberdeps Quick Question

I’ve got nicely automated uberjar’ing in my deps.edn

....
:aliases
{:uberjar {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.0.193"}}
           :exec-fn hf.depstar/uberjar
           :exec-args {:aot true :jar myapp.jar :main-class myapp.core}
           :jvm-opts ["-ea" ; disable assertions
                      "-Dclojure.compiler.direct-linking=true"] 
           }}

This allows me to run clojure -M:uberjar clojure -X:uberjar to get my jar file. Yay, all is well.
The resulting jar was a bit large, so I wondered how to reduce the size of it. I figured I would try Uberdeps, and see if there was a difference.

Now I found uberdeps, and tried to do the same, with little success. I did never get it to run. And all the examples use additional shell scripts to get it to work (which I don’t want).

Does anyone know how to get a nice deps.edn task for uberdeps?

I think at this point pretty much everyone uses depstar. If you’re building an uberjar, it’s going to contain all of Clojure’s runtime and any other dependencies your project needs so it’s going to be “big”. Here’s what you should expect for a bare-bones “Hello, World!” project:

(! 866)-> clojure -X:new :name magnus/example
Generating a project called example based on the 'app' template.
(! 867)-> cd example/
(! 868)-> clojure -X:uberjar
[main] INFO hf.depstar.uberjar - Synchronizing pom.xml
Skipping paths: resources
[main] INFO hf.depstar.uberjar - Compiling magnus.example ...
[main] INFO hf.depstar.uberjar - Building uber jar: example.jar
[main] INFO hf.depstar.uberjar - Processing pom.xml for {net.clojars.magnus/example {:mvn/version "0.1.0-SNAPSHOT"}}
(! 869)-> ls -l example.jar 
-rw-r--r--  1 sean  staff  4714314 Mar 16 09:43 example.jar

About four and a half MB.

Note that your :jvm-opts will only affect depstar itself – those options will not be passed to the compilation process. It needs to be inside the :exec-args for it to apply to the compilation process, or supplied on the command-line when you run clojure -X:uberjar. I’ll make that clearer in the README.

Also, you show clojure -M:uberjar but I think you mean clojure -X:uberjar?

Thanks! I learned something.

and yes, I meant clojure -X:uberjar

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.