Skip to content

Commit

Permalink
Propagate failure return values a bit better in install/jar.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Oct 19, 2011
1 parent c43f7a4 commit d309b4b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/leiningen/install.clj
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions src/leiningen/jar.clj
Expand Up @@ -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)))
2 changes: 1 addition & 1 deletion test/leiningen/test/install.clj
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion test/leiningen/test/jar.clj
Expand Up @@ -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
Expand Down

0 comments on commit d309b4b

Please sign in to comment.