Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create multiple uberjars in leiningen

I want to create a number of uberjars with different main entrypoints from a single codebase. I see you can specify the main namespace as an argument to lein uberjar but I don't see a way to specify the resulting filename or path, so they'll just overwrite one another. Is there a way to override the output filename or path from the command line?

Or is there a better way of doing this? Have separate project files that all reference a central "library" project? If so, what would the physical structure of this look like and how to get it to build?

like image 307
Dax Fohl Avatar asked Oct 12 '13 12:10

Dax Fohl


2 Answers

You can use multiple Leiningen profiles to accomplish what you are talking about.

(defproject project1 "0.1.0-SNAPSHOT"
  :description "Something Amazing!"
  :dependencies [[org.clojure/clojure "1.5.1"]]
  :profiles {:v1 {:main project1.core1
                  :uberjar-name "uberjar1.jar"}
             :v2 {:main project1.core2
                  :uberjar-name "uberjar2.jar"}
             :v3 {:main project1.core3
                  :uberjar-name "uberjar3.jar"}})

And, you can build them with:

$ lein with-profile v1:v2:v3 uberjar
like image 97
Jared314 Avatar answered Oct 20 '22 07:10

Jared314


Here is an annotated reference source where you can find an option for specifying a name of your output jar or uberjar file and any other options that may be set in a project.clj file.

;;; Jar Output
;; Name of the jar file produced. Will be placed inside :target-path.
;; Including %s will splice the project version into the filename.
:jar-name "sample.jar"
;; As above, but for uberjar.
:uberjar-name "sample-standalone.jar"
like image 25
Aleksei Sotnikov Avatar answered Oct 20 '22 07:10

Aleksei Sotnikov