Added a build-failing project for flexing compilation-failing aware 'jar'; created test_projects and moved sample there too
This commit is contained in:
parent
3f4e557d80
commit
93535c5a17
18 changed files with 73 additions and 26 deletions
|
@ -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
|
||||
(let [exit-status (eval-in-project project
|
||||
`(doseq [namespace# '~namespaces]
|
||||
(when-not ~*silently*
|
||||
(println "Compiling" namespace#))
|
||||
(clojure.core/compile namespace#))
|
||||
nil :skip-auto-compile)
|
||||
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*
|
||||
|
|
|
@ -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))
|
||||
(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))
|
||||
jar-path))))
|
||||
([project] (jar project (get-default-jar-name project))))
|
||||
|
|
|
@ -60,7 +60,8 @@
|
|||
the dependency jars. Suitable for standalone distribution."
|
||||
([project uberjar-name]
|
||||
(doto project
|
||||
clean deps jar)
|
||||
clean deps)
|
||||
(if (jar project)
|
||||
(let [standalone-filename (get-jar-filename project uberjar-name)]
|
||||
(with-open [out (-> standalone-filename
|
||||
(FileOutputStream.)
|
||||
|
@ -69,5 +70,9 @@ the dependency jars. Suitable for standalone distribution."
|
|||
(filter #(.endsWith (.getName %) ".jar"))
|
||||
(cons (file (get-jar-filename project))))]
|
||||
(write-components deps out)))
|
||||
(println "Created" standalone-filename)))
|
||||
(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))))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))))
|
||||
|
|
|
@ -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")]
|
||||
|
|
4
test_projects/README.txt
Normal file
4
test_projects/README.txt
Normal file
|
@ -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".
|
9
test_projects/sample_failing/project.clj
Normal file
9
test_projects/sample_failing/project.clj
Normal file
|
@ -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]])
|
13
test_projects/sample_failing/src/nom/nom/nom.clj
Normal file
13
test_projects/sample_failing/src/nom/nom/nom.clj
Normal file
|
@ -0,0 +1,13 @@
|
|||
(ns nom.nom.nom
|
||||
(:gen-class))
|
||||
|
||||
This noming squirrel will cause compilation of this file to fail.
|
||||
|
||||
,;;:;,
|
||||
;;;;;
|
||||
,:;;:; ,'=.
|
||||
;:;:;' .=" ,'_\
|
||||
':;:;,/ ,__:=@
|
||||
';;:; =./)_
|
||||
`"=\_ )_"`
|
||||
``'"
|
Loading…
Reference in a new issue