Update uberjar for new api

This commit is contained in:
Nelson Morris 2012-01-21 20:52:44 -06:00
parent ef2b0f0b9b
commit 39892e19fa
4 changed files with 12 additions and 15 deletions

View file

@ -116,8 +116,9 @@
(defmethod copy-to-jar :path [project jar-os spec] (defmethod copy-to-jar :path [project jar-os spec]
(doseq [child (file-seq (io/file (:path spec)))] (doseq [child (file-seq (io/file (:path spec)))]
(let [path (trim-leading-str (unix-path (str child)) (let [path (trim-leading-str (trim-leading-str (unix-path (str child))
(unix-path (:path spec)))] (unix-path (:path spec)))
"/")]
(when-not (skip-file? child path (:jar-exclusions project)) (when-not (skip-file? child path (:jar-exclusions project))
(.putNextEntry jar-os (doto (JarEntry. path) (.putNextEntry jar-os (doto (JarEntry. path)
(.setTime (.lastModified child)))) (.setTime (.lastModified child))))

View file

@ -1,12 +1,12 @@
(ns leiningen.uberjar (ns leiningen.uberjar
"Package up the project files and deps into a jar file." "Package up the project files and deps into a jar file."
(:require [clojure.xml :as xml]) (:require [clojure.xml :as xml]
[leiningen.core.classpath :as classpath])
(:use [clojure.zip :only [xml-zip children]] (:use [clojure.zip :only [xml-zip children]]
[clojure.java.io :only [file copy]] [clojure.java.io :only [file copy]]
[leiningen.core :only [abort]] [leiningen.core.main :only [abort]]
[leiningen.clean :only [clean]] [leiningen.clean :only [clean]]
[leiningen.jar :only [get-jar-filename jar]] [leiningen.jar :only [get-jar-filename jar]])
[leiningen.deps :only [deps]])
(:import (java.util.zip ZipFile ZipOutputStream ZipEntry) (:import (java.util.zip ZipFile ZipOutputStream ZipEntry)
(java.io File FileOutputStream PrintWriter))) (java.io File FileOutputStream PrintWriter)))
@ -85,7 +85,7 @@ as well as defining a -main function."
(with-open [out (-> standalone-filename (with-open [out (-> standalone-filename
(FileOutputStream.) (FileOutputStream.)
(ZipOutputStream.))] (ZipOutputStream.))]
(let [deps (->> (.listFiles (file (:library-path project))) (let [deps (->> (classpath/resolve-dependencies project)
(filter #(.endsWith (.getName %) ".jar"))) (filter #(.endsWith (.getName %) ".jar")))
jars (cons (file (get-jar-filename project)) deps)] jars (cons (file (get-jar-filename project)) deps)]
(write-components project jars out))) (write-components project jars out)))

View file

@ -1,13 +1,11 @@
(ns leiningen.test.uberjar (ns leiningen.test.uberjar
(:use [leiningen.uberjar] :reload) (:use [leiningen.uberjar] :reload)
(:use [clojure.test] (:use [clojure.test]
[leiningen.jar :only [jar]] [leiningen.test.helper :only [sample-no-aot-project]])
[leiningen.core :only [read-project]]
[leiningen.test.helper :only [sample-no-aot-project]])
(:import [java.util.zip ZipFile])) (:import [java.util.zip ZipFile]))
(deftest test-uberjar (deftest test-uberjar
(let [filename "TODO" (let [filename "test_projects/sample_no_aot/target/nomnomnom-0.5.0-SNAPSHOT-standalone.jar"
_ (with-out-str (uberjar sample-no-aot-project)) _ (with-out-str (uberjar sample-no-aot-project))
entries (->> (ZipFile. filename) entries (->> (ZipFile. filename)
.entries .entries
@ -16,6 +14,4 @@
set)] set)]
(is (entries "nom/nom/nom.clj")) (is (entries "nom/nom/nom.clj"))
(is (entries "org/codehaus/janino/Compiler$1.class")) (is (entries "org/codehaus/janino/Compiler$1.class"))
(is (not (some #(re-find #"dummy" %) entries))))) (is (not (some #(re-find #"dummy" %) entries)))))
(doseq [[_ var] (ns-publics *ns*)] (alter-meta! var assoc :busted true))

View file

@ -52,7 +52,7 @@ See also https://github.com/technomancy/leiningen/issues
- [X] search - [X] search
- [X] pom (steal from depot) - [X] pom (steal from depot)
- [ ] install (minus shell wrappers) - [ ] install (minus shell wrappers)
- [ ] uberjar - [X] uberjar
- [ ] repl (figure out nrepl integration) - [ ] repl (figure out nrepl integration)
*** Tasks for full release (currently tagged :busted) *** Tasks for full release (currently tagged :busted)
- [ ] deps (native-deps and :repositories options) - [ ] deps (native-deps and :repositories options)