Place the project jar last in the uberjar. Fixes #178.

This commit is contained in:
Phil Hagelberg 2011-03-02 22:10:15 -08:00
parent cdc38473f8
commit 6e7aa2629c

View file

@ -49,11 +49,11 @@
(defn write-components (defn write-components
"Given a list of jarfiles, writes contents to a stream" "Given a list of jarfiles, writes contents to a stream"
[project deps out] [project jars out]
(let [[_ components] (reduce (partial include-dep out (let [[_ components] (reduce (partial include-dep out
(make-skip-pred project)) (make-skip-pred project))
[#{"META-INF/plexus/components.xml"} nil] [#{"META-INF/plexus/components.xml"} nil]
deps)] jars)]
(when-not (empty? components) (when-not (empty? components)
(.putNextEntry out (ZipEntry. "META-INF/plexus/components.xml")) (.putNextEntry out (ZipEntry. "META-INF/plexus/components.xml"))
(binding [*out* (PrintWriter. out)] (binding [*out* (PrintWriter. out)]
@ -69,17 +69,16 @@
"Create a jar like the jar task, but including the contents of each of "Create a jar like the jar task, but including the contents of each of
the dependency jars. Suitable for standalone distribution." the dependency jars. Suitable for standalone distribution."
([project uberjar-name] ([project uberjar-name]
(doto project (doto project clean deps)
clean deps)
(if (jar project) (if (jar project)
(let [standalone-filename (get-jar-filename project uberjar-name)] (let [standalone-filename (get-jar-filename project uberjar-name)]
(with-open [out (-> standalone-filename (with-open [out (-> standalone-filename
(FileOutputStream.) (FileOutputStream.)
(ZipOutputStream.))] (ZipOutputStream.))]
(let [deps (->> (.listFiles (file (:library-path project))) (let [deps (->> (.listFiles (file (:library-path project)))
(filter #(.endsWith (.getName %) ".jar")) (filter #(.endsWith (.getName %) ".jar")))
(cons (file (get-jar-filename project))))] jars (conj (vec deps) (file (get-jar-filename project)))]]
(write-components project deps out))) (write-components project jars out)))
(println "Created" standalone-filename)) (println "Created" standalone-filename))
(abort "Uberjar aborting because jar/compilation failed."))) (abort "Uberjar aborting because jar/compilation failed.")))
([project] (uberjar project (get-default-uberjar-name project)))) ([project] (uberjar project (get-default-uberjar-name project))))