Create a jar like the jar task, but including the contents of each of
the dependency jars. Suitable for standalone distribution.
(defn uberjar
"Create a jar like the jar task, but including the contents of each of
the dependency jars. Suitable for standalone distribution."
([project uberjar-name]
(clean project)
(jar project)
(let [standalone-filename (get-jar-filename project uberjar-name)]
(with-open [out (-> (file standalone-filename)
(FileOutputStream.) (ZipOutputStream.))]
(let [deps (->> (.listFiles (file (:library-path project)))
(filter #(.endsWith (.getName %) ".jar"))
(cons (file (get-jar-filename
project (get-default-jar-name project)))))
[_ components] (reduce (partial include-dep out)
[#{"META-INF/plexus/components.xml"} nil]
deps)]
(when-not (empty? components)
(.putNextEntry out (ZipEntry. "META-INF/plexus/components.xml"))
(binding [*out* (PrintWriter. out)]
(xml/emit {:tag :component-set
:content
[{:tag :components
:content
components}]})
(.flush *out*))
(.closeEntry out))))
(println "Created" standalone-filename)))
([project] (uberjar project (get-default-uberjar-name project))))
Comments top
No comments for uberjar. Log in to add a comment.