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?


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

这里有一个带注释的参考资源,您可以在其中找到一个选项,用于指定输出jar或uberjar文件的名称以及可以在project.clj文件中设置的任何其他选项。

;;; 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"
链接地址: http://www.djcxy.com/p/51738.html

上一篇: Leiningen生产Uberjars的错误还是误解?

下一篇: 在leiningen创建多个uberjars