简体   繁体   English

在莱宁根创造多个uberjars

[英]create multiple uberjars in leiningen

I want to create a number of uberjars with different main entrypoints from a single codebase. 我想从单个代码库创建一些具有不同main入口点的uberjars。 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. 我看到你可以指定main命名空间作为lein uberjar的参数,但我没有看到指定结果文件名或路径的方法,因此它们只会相互覆盖。 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. 您可以使用多个Leiningen配置文件来完成您所说的内容。

(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

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或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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM