Skip to content

Commit

Permalink
Move *interactive?* flag to leiningen.core.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Jun 19, 2011
1 parent 1c7a5f0 commit 408b07a
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -77,13 +77,13 @@ advantage of this, you should put it on your <tt>$PATH</tt>.


## Configuration ## Configuration


Place a <tt>project.clj</tt> file in the project root like this: The <tt>project.clj</tt> file in the project root should look like this:


(defproject myproject "0.5.0-SNAPSHOT" (defproject myproject "0.5.0-SNAPSHOT"
:description "A build tool designed to not set your hair on fire." :description "A build tool designed to not set your hair on fire."
:url "http://github.com/technomancy/leiningen" :url "http://github.com/technomancy/leiningen"
:dependencies [[org.clojure/clojure "1.1.0"] :dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.1.0"]] [org.clojure/clojure-contrib "1.2.0"]]
:dev-dependencies [[swank-clojure "1.2.1"]]) :dev-dependencies [[swank-clojure "1.2.1"]])


The <tt>lein new</tt> task generates a project skeleton with an The <tt>lein new</tt> task generates a project skeleton with an
Expand Down
12 changes: 9 additions & 3 deletions src/leiningen/compile.clj
@@ -1,7 +1,7 @@
(ns leiningen.compile (ns leiningen.compile
"Compile Clojure source into .class files." "Compile Clojure source into .class files."
(:use [leiningen.deps :only [deps find-jars]] (:use [leiningen.deps :only [deps find-jars]]
[leiningen.core :only [defdeprecated user-settings]] [leiningen.core :only [defdeprecated user-settings *interactive?*]]
[leiningen.javac :only [javac]] [leiningen.javac :only [javac]]
[leiningen.classpath :only [make-path get-classpath]] [leiningen.classpath :only [make-path get-classpath]]


Expand Down Expand Up @@ -111,7 +111,14 @@
~(injected-forms) ~(injected-forms)
(set! ~'*warn-on-reflection* (set! ~'*warn-on-reflection*
~(:warn-on-reflection project)) ~(:warn-on-reflection project))
~form)] (try ~form
;; non-daemon threads will prevent process from exiting;
;; see http://tinyurl.com/2ueqjkl
(finally
(when-not (or (= "1.5" (System/getProperty
"java.specification.version"))
~*interactive?*)
(shutdown-agents)))))]
;; work around java's command line handling on windows ;; work around java's command line handling on windows
;; http://bit.ly/9c6biv This isn't perfect, but works for what's ;; http://bit.ly/9c6biv This isn't perfect, but works for what's
;; currently being passed; see ;; currently being passed; see
Expand Down Expand Up @@ -162,7 +169,6 @@
(when (:debug project) (when (:debug project)
(add-system-property java :clojure.debug true)) (add-system-property java :clojure.debug true))
(when (.exists (file (:native-path project))) (when (.exists (file (:native-path project)))
;; TODO: support fn in :native-path?
(add-system-property java "java.library.path" (:native-path project))) (add-system-property java "java.library.path" (:native-path project)))
(.setClasspath java (apply make-path (get-classpath project))) (.setClasspath java (apply make-path (get-classpath project)))
(.setFailonerror java true) (.setFailonerror java true)
Expand Down
2 changes: 2 additions & 0 deletions src/leiningen/core.clj
Expand Up @@ -9,6 +9,8 @@
(:import (java.io File) (:import (java.io File)
(org.apache.maven.artifact.versioning DefaultArtifactVersion))) (org.apache.maven.artifact.versioning DefaultArtifactVersion)))


(def *interactive?* false)

(defmacro defdeprecated [old new] (defmacro defdeprecated [old new]
`(let [new# ~(str (.getName (:ns (meta (resolve new)))) "/" (name new)) `(let [new# ~(str (.getName (:ns (meta (resolve new)))) "/" (name new))
warn# (delay (println "Warning:" '~old "is deprecated; use" new#))] warn# (delay (println "Warning:" '~old "is deprecated; use" new#))]
Expand Down
1 change: 1 addition & 0 deletions src/leiningen/deps.clj
Expand Up @@ -68,6 +68,7 @@
(lancet/copy {:todir destination :flatten (if flatten? "on" "off")} (lancet/copy {:todir destination :flatten (if flatten? "on" "off")}
fileset)) fileset))


;; TODO: remove in 2.0; with local-repo-classpath it's unnecessary
(defmethod copy-dependencies :symlink [k destination flatten? fileset] (defmethod copy-dependencies :symlink [k destination flatten? fileset]
(let [files (.getIncludedFiles (let [files (.getIncludedFiles
(.getDirectoryScanner fileset lancet/ant-project)) (.getDirectoryScanner fileset lancet/ant-project))
Expand Down
4 changes: 1 addition & 3 deletions src/leiningen/interactive.clj
@@ -1,7 +1,7 @@
(ns leiningen.interactive (ns leiningen.interactive
"Enter interactive task shell." "Enter interactive task shell."
(:require [clojure.string :as string]) (:require [clojure.string :as string])
(:use [leiningen.core :only [apply-task exit]] (:use [leiningen.core :only [apply-task exit *interactive*]]
[leiningen.test :only [*exit-after-tests*]] [leiningen.test :only [*exit-after-tests*]]
[leiningen.repl :only [repl-server repl-socket-on [leiningen.repl :only [repl-server repl-socket-on
copy-out-loop poll-repl-connection]] copy-out-loop poll-repl-connection]]
Expand All @@ -11,8 +11,6 @@


(def prompt "lein> ") (def prompt "lein> ")


(def *interactive* false)

(defn not-found [& _] (defn not-found [& _]
(println "That's not a task. Use help to list all tasks.")) (println "That's not a task. Use help to list all tasks."))


Expand Down
7 changes: 2 additions & 5 deletions src/leiningen/test.clj
Expand Up @@ -2,6 +2,7 @@
"Run the project's tests." "Run the project's tests."
(:refer-clojure :exclude [test]) (:refer-clojure :exclude [test])
(:use [clojure.java.io :only [file]] (:use [clojure.java.io :only [file]]
[leiningen.core :only [*interactive?*]]
[leiningen.util.ns :only [namespaces-in-dir]] [leiningen.util.ns :only [namespaces-in-dir]]
[leiningen.compile :only [eval-in-project]]) [leiningen.compile :only [eval-in-project]])
(:import (java.io File))) (:import (java.io File)))
Expand Down Expand Up @@ -38,16 +39,12 @@ each namespace and print an overall summary."
summary# (binding [clojure.test/*test-out* *out*] summary# (binding [clojure.test/*test-out* *out*]
(apply ~'clojure.test/run-tests '~namespaces))] (apply ~'clojure.test/run-tests '~namespaces))]
(spit ".lein-failures" (pr-str @failures#)) (spit ".lein-failures" (pr-str @failures#))
(when (and (not= "1.5" (System/getProperty
"java.specification.version"))
~*exit-after-tests*)
(shutdown-agents))
;; Stupid ant won't let us return anything, so write results to disk ;; Stupid ant won't let us return anything, so write results to disk
(with-open [w# (-> (java.io.File. ~result-file) (with-open [w# (-> (java.io.File. ~result-file)
(java.io.FileOutputStream.) (java.io.FileOutputStream.)
(java.io.OutputStreamWriter.))] (java.io.OutputStreamWriter.))]
(.write w# (pr-str summary#))) (.write w# (pr-str summary#)))
(when ~*exit-after-tests* (when-not ~*interactive?*
(System/exit 0)))))) (System/exit 0))))))


(defn- read-args [args project] (defn- read-args [args project]
Expand Down
3 changes: 1 addition & 2 deletions todo.org
Expand Up @@ -38,11 +38,10 @@ See also https://github.com/technomancy/leiningen/issues
- new push task based on clj-ssh - new push task based on clj-ssh
lein-clojars task doesn't support DSA keys lein-clojars task doesn't support DSA keys
* For 1.6 * For 1.6
- [ ] move exit-after-tests check to eval-in-project (discuss on list?)
- [ ] upgrade new task
- [ ] suppress useless ant output in classpath calculation for :local-repo-classpath - [ ] suppress useless ant output in classpath calculation for :local-repo-classpath
- [ ] Trampoline functionality - [ ] Trampoline functionality
http://groups.google.com/group/leiningen/browse_thread/thread/a07a7f10edb77c9b http://groups.google.com/group/leiningen/browse_thread/thread/a07a7f10edb77c9b
- [x] move exit-after-tests check to eval-in-project (discuss on list?)
- [x] don't freak out when attempting to download non-existent indices - [x] don't freak out when attempting to download non-existent indices
- [x] improve error message for unconfigured deploy - [x] improve error message for unconfigured deploy
- [x] make search work outside project - [x] make search work outside project
Expand Down

0 comments on commit 408b07a

Please sign in to comment.