Skip to content

Commit

Permalink
Added a build-failing project for flexing compilation-failing aware '…
Browse files Browse the repository at this point in the history
…jar'; created test_projects and moved sample there too
  • Loading branch information
alandipert committed Aug 24, 2010
1 parent 3f4e557 commit 93535c5
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 26 deletions.
17 changes: 11 additions & 6 deletions src/leiningen/compile.clj
Expand Up @@ -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*
Expand Down
12 changes: 6 additions & 6 deletions src/leiningen/jar.clj
Expand Up @@ -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))))
25 changes: 15 additions & 10 deletions src/leiningen/uberjar.clj
Expand Up @@ -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))))
2 changes: 1 addition & 1 deletion test/test_deps.clj
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/test_install.clj
Expand Up @@ -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)
Expand Down
13 changes: 12 additions & 1 deletion test/test_jar.clj
Expand Up @@ -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))
Expand All @@ -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))))
2 changes: 1 addition & 1 deletion test/test_pom.clj
Expand Up @@ -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")]
Expand Down
4 changes: 4 additions & 0 deletions 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".
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions 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]])
13 changes: 13 additions & 0 deletions 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.