Propagate failure return values a bit better in install/jar.

This commit is contained in:
Phil Hagelberg 2011-10-19 15:58:32 -07:00
parent c43f7a487d
commit d309b4b057
4 changed files with 14 additions and 9 deletions

View file

@ -46,17 +46,21 @@ in your local repository. With two arguments, (group/name and version)
downloads and installs a project from a remote repository. Places
shell wrappers in ~/.lein/bin when provided."
([project]
(let [jarfile (file (jar project))
(let [jarfile (jar project)
model (make-model project)
artifact (make-artifact model)
installer (.lookup container ArtifactInstaller/ROLE)
local-repo (make-local-repo)]
;; for packaging other than "pom" there should be "pom.xml"
;; generated and installed in local repo
(if (not= "pom" (.getPackaging model))
(when (not= "pom" (.getPackaging model))
(add-metadata artifact (file (pom project))))
(install-shell-wrappers (JarFile. jarfile))
(.install installer jarfile artifact local-repo)))
(if (number? jarfile)
;; if we failed to create the jar, return the status code for exit
jarfile
(do (install-shell-wrappers (JarFile. jarfile))
(.install installer (file jarfile) artifact local-repo)
0))))
([project-name version]
(let [[name group] ((juxt name namespace) (symbol project-name))
_ (standalone-download name (or group name) version)

View file

@ -202,11 +202,12 @@ function in that namespace will be used as the main-class for executable jar."
([project jar-name]
(when jar-name
(println "WARNING: Using the jar task with an argument is deprecated."))
(binding [compile/*silently* true]
(when (zero? (compile/compile project))
(let [status (compile/compile project)]
(if (zero? status)
(let [jar-path (get-jar-filename project (get-default-jar-name project))
deps-fileset (deps project)]
(write-jar project jar-path (filespecs project deps-fileset))
(println "Created" jar-path)
jar-path))))
jar-path)
status)))
([project] (jar project nil)))

View file

@ -17,7 +17,7 @@
(deftest test-install
(delete-file-recursively (m2-dir "nomnomnom" "0.5.0-SNAPSHOT") true)
(delete-shell-wrappers)
(install sample-project)
(is (zero? (install sample-project)))
(is (not (empty? (.listFiles (m2-dir "nomnomnom" "0.5.0-SNAPSHOT")))))
(is (.exists unix-shell-wrapper))
(if (= :windows (get-os))

View file

@ -47,7 +47,7 @@
(deftest test-jar-fails
(binding [*err* (java.io.PrintWriter. (platform-nullsink))]
(is (not (jar sample-failing-project)))))
(is (pos? (jar sample-failing-project)))))
(deftest test-no-aot-jar-succeeds
(with-out-str