• (uberjar project uberjar-name)
  • (uberjar project)
Create a jar like the jar task, but including the contents of each of
the dependency jars. Suitable for standalone distribution.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source leiningen/uberjar.clj:45 top

(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))))
Vars in leiningen.uberjar/uberjar: *out* binding defn empty? let println when-not with-open
Used in 0 other vars

Comments top

No comments for uberjar. Log in to add a comment.