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]
(doseq [child (file-seq (io/file (:path spec)))]
(let [path (trim-leading-str (unix-path (str child))
(unix-path (:path spec)))]
(let [path (trim-leading-str (trim-leading-str (unix-path (str child))
(unix-path (:path spec)))
"/")]
(when-not (skip-file? child path (:jar-exclusions project))
(.putNextEntry jar-os (doto (JarEntry. path)
(.setTime (.lastModified child))))

View file

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

View file

@ -1,13 +1,11 @@
(ns leiningen.test.uberjar
(:use [leiningen.uberjar] :reload)
(:use [clojure.test]
[leiningen.jar :only [jar]]
[leiningen.core :only [read-project]]
[leiningen.test.helper :only [sample-no-aot-project]])
[leiningen.test.helper :only [sample-no-aot-project]])
(:import [java.util.zip ZipFile]))
(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))
entries (->> (ZipFile. filename)
.entries
@ -17,5 +15,3 @@
(is (entries "nom/nom/nom.clj"))
(is (entries "org/codehaus/janino/Compiler$1.class"))
(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] pom (steal from depot)
- [ ] install (minus shell wrappers)
- [ ] uberjar
- [X] uberjar
- [ ] repl (figure out nrepl integration)
*** Tasks for full release (currently tagged :busted)
- [ ] deps (native-deps and :repositories options)