Skip to content
Browse files

Added a build-failing project for flexing compilation-failing aware '…

…jar'; created test_projects and moved sample there too
  • Loading branch information...
1 parent 3f4e557 commit 93535c5a17df197ba8ee5470da49b2a22e096492 @alandipert alandipert committed
View
17 src/leiningen/compile.clj
@@ -154,12 +154,17 @@ those given as command-line arguments."
(.mkdir (file (:compile-path project)))
(if (seq (compilable-namespaces project))
(if-let [namespaces (seq (stale-namespaces project))]
- (eval-in-project project
- `(doseq [namespace# '~namespaces]
- (when-not ~*silently*
- (println "Compiling" namespace#))
- (clojure.core/compile namespace#))
- nil :skip-auto-compile)
+ (let [exit-status (eval-in-project project
+ `(doseq [namespace# '~namespaces]
+ (when-not ~*silently*
+ (println "Compiling" namespace#))
+ (clojure.core/compile namespace#))
+ nil :skip-auto-compile)]
+ (if (= 1 exit-status)
+ (do (binding [*out* *err*]
+ (println "Compilation failed."))
+ false)
+ true))
(when-not *silently*
(println "All namespaces already :aot compiled.")))
(when-not *silently*
View
12 src/leiningen/jar.clj
@@ -154,10 +154,10 @@ well as the source .clj files. If project.clj contains a :main symbol, it will
be used as the main-class for an executable jar."
([project jar-name]
(binding [compile/*silently* true]
- (compile/compile project))
- (let [jar-path (get-jar-filename project jar-name)
- deps-fileset (deps project :skip-dev)]
- (write-jar project jar-path (filespecs project deps-fileset))
- (println "Created" jar-path)
- jar-path))
+ (when (compile/compile project)
+ (let [jar-path (get-jar-filename project jar-name)
+ deps-fileset (deps project :skip-dev)]
+ (write-jar project jar-path (filespecs project deps-fileset))
+ (println "Created" jar-path)
+ jar-path))))
([project] (jar project (get-default-jar-name project))))
View
25 src/leiningen/uberjar.clj
@@ -60,14 +60,19 @@
the dependency jars. Suitable for standalone distribution."
([project uberjar-name]
(doto project
- clean deps jar)
- (let [standalone-filename (get-jar-filename project uberjar-name)]
- (with-open [out (-> standalone-filename
- (FileOutputStream.)
- (ZipOutputStream.))]
- (let [deps (->> (.listFiles (file (:library-path project)))
- (filter #(.endsWith (.getName %) ".jar"))
- (cons (file (get-jar-filename project))))]
- (write-components deps out)))
- (println "Created" standalone-filename)))
+ clean deps)
+ (if (jar project)
+ (let [standalone-filename (get-jar-filename project uberjar-name)]
+ (with-open [out (-> standalone-filename
+ (FileOutputStream.)
+ (ZipOutputStream.))]
+ (let [deps (->> (.listFiles (file (:library-path project)))
+ (filter #(.endsWith (.getName %) ".jar"))
+ (cons (file (get-jar-filename project))))]
+ (write-components deps out)))
+ (println "Created" standalone-filename))
+ (do
+ (binding [*out* *err*]
+ (println "Uberjar aborting because jar/compilation failed."))
+ (System/exit 1))))
([project] (uberjar project (get-default-uberjar-name project))))
View
2 test/test_deps.clj
@@ -5,7 +5,7 @@
[clojure.contrib.set]
[clojure.contrib.io :only [file delete-file-recursively]]))
-(def test-project (read-project "sample/project.clj"))
+(def test-project (read-project "test_projects/sample/project.clj"))
(deftest test-deps
(delete-file-recursively (file (:root test-project) "lib") true)
View
2 test/test_install.clj
@@ -8,7 +8,7 @@
(def m2-dir (file (System/getProperty "user.home") ".m2" "repository"
"nomnomnom" "nomnomnom" "0.5.0-SNAPSHOT"))
-(defonce test-project (read-project "sample/project.clj"))
+(defonce test-project (read-project "test_projects/sample/project.clj"))
(deftest test-install
(delete-file-recursively m2-dir true)
View
13 test/test_jar.clj
@@ -14,7 +14,7 @@
(select-keys manifest ["hello" "Main-Class"])))))
(def sample-project (binding [*ns* (the-ns 'leiningen.core)]
- (read-project "sample/project.clj")))
+ (read-project "test_projects/sample/project.clj")))
(deftest test-jar
(let [jar-file (JarFile. (jar sample-project))
@@ -30,3 +30,14 @@
manifest (manifest-map (.getManifest jar-file))]
(is (nil? (.getEntry jar-file "bin/nom")))
(is (nil? (manifest "Leiningen-shell-wrapper")))))
+
+(def sample-failing-project
+ (binding [*ns* (the-ns 'leiningen.core)]
+ (read-project "test_projects/sample_failing/project.clj")))
+
+(deftest test-jar-fails
+ (println "**********************************************")
+ (println "***** You're about to see a stack trace. *****")
+ (println "***** Stay cool, it's part of the test. *****")
+ (println "**********************************************")
+ (is (not (jar sample-failing-project))))
View
2 test/test_pom.clj
@@ -5,7 +5,7 @@
(:use [clojure.test]
[clojure.contrib.io :only [file delete-file]]))
-(def test-project (read-project "sample/project.clj"))
+(def test-project (read-project "test_projects/sample/project.clj"))
(deftest test-pom
(let [pom-file (file (:root test-project) "pom.xml")]
View
4 test_projects/README.txt
@@ -0,0 +1,4 @@
+These projects are used for leiningen's test suite, so don't change
+any of these values without updating the relevant tests. If you
+just want a basic project to work from, generate a new one with
+"lein new".
View
0 sample/checkouts/sample2/.gitignore → ...jects/sample/checkouts/sample2/.gitignore
File renamed without changes.
View
0 sample/checkouts/sample2/README → ..._projects/sample/checkouts/sample2/README
File renamed without changes.
View
0 sample/checkouts/sample2/project.clj → ...ects/sample/checkouts/sample2/project.clj
File renamed without changes.
View
0 ...le/checkouts/sample2/src/sample2/core.clj → ...le/checkouts/sample2/src/sample2/core.clj
File renamed without changes.
View
0 ...ckouts/sample2/test/sample2/core_test.clj → ...ckouts/sample2/test/sample2/core_test.clj
File renamed without changes.
View
0 sample/project.clj → test_projects/sample/project.clj
File renamed without changes.
View
0 sample/src/nom/nom/nom.clj → test_projects/sample/src/nom/nom/nom.clj
File renamed without changes.
View
0 sample/test/test_nom_nom_nom.clj → ...projects/sample/test/test_nom_nom_nom.clj
File renamed without changes.
View
9 test_projects/sample_failing/project.clj
@@ -0,0 +1,9 @@
+;; This project is used for leiningen's test suite, so don't change
+;; any of these values without updating the relevant tests. If you
+;; just want a basic project to work from, generate a new one with
+;; "lein new".
+
+(def clj-version "1.1.0-master-SNAPSHOT")
+
+(defproject nomnomnom "0.5.0-SNAPSHOT"
+ :dependencies [[~(symbol "org.clojure" "clojure") ~clj-version]])
View
13 test_projects/sample_failing/src/nom/nom/nom.clj
@@ -0,0 +1,13 @@
+(ns nom.nom.nom
+ (:gen-class))
+
+This noming squirrel will cause compilation of this file to fail.
+
+ ,;;:;,
+ ;;;;;
+ ,:;;:; ,'=.
+ ;:;:;' .=" ,'_\
+ ':;:;,/ ,__:=@
+ ';;:; =./)_
+ `"=\_ )_"`
+ ``'"

0 comments on commit 93535c5

Please sign in to comment.
Something went wrong with that request. Please try again.