Move away from build.clj to project.clj.

This commit is contained in:
Phil Hagelberg 2009-11-05 20:36:27 -08:00
parent 08025038c0
commit 79b969b425
7 changed files with 23 additions and 17 deletions

View file

@ -23,11 +23,11 @@ in the root and http://p.hagelb.org/lancet.clj on the classpath.
$ lein repl # launch a REPL with the project classpath configured $ lein repl # launch a REPL with the project classpath configured
TODO: jar, uberjar, swank, new, help, deploy TODO: jar, uberjar, swank, new, help, deploy, pom
## Configuration ## Configuration
Place a build.clj file in the project root that looks something like this: Place a project.clj file in the project root that looks something like this:
(defproject leiningen (defproject leiningen
:version "1.0-SNAPSHOT" :version "1.0-SNAPSHOT"
@ -73,5 +73,8 @@ Place a build.clj file in the project root that looks something like this:
Copyright (C) 2009 Phil Hagelberg Copyright (C) 2009 Phil Hagelberg
Thanks to Stuart Halloway for Lancet and Tim Dysinger for convincing
me that good builds are important.
Distributed under the Eclipse Public License, the same as Clojure Distributed under the Eclipse Public License, the same as Clojure
uses. See the file COPYING. uses. See the file COPYING.

View file

@ -1,10 +1,12 @@
#!/bin/bash #!/bin/bash
if [ -r "bin/lein" ]; then LIBS="$(find -H lib/ -mindepth 1 -maxdepth 1 -print0 | tr \\0 \:)"
LIBS="$(find -H lib/ -mindepth 1 -maxdepth 1 -print0 | tr \\0 \:)"
CLASSPATH=src/:classes/:$LIBS CLASSPATH="src/:classes/:$LIBS"
else
CLASSPATH="$HOME/.m2/repository/org/clojure/lancet/1.0-SNAPSHOT/lancet-1.0-SNAPSHOT.jar" if [ ! -r "bin/lein" ]; then
# If we are not running from a checkout
CLASSPATH="$CLASSPATH:$HOME/.leiningen.jar"
fi fi
if [ $1 = "test" ]; then if [ $1 = "test" ]; then
@ -12,12 +14,8 @@ if [ $1 = "test" ]; then
fi fi
if [ $1 = "repl" ]; then if [ $1 = "repl" ]; then
# TODO: fix for eshell # If repl used leiningen.core then there'd be no way to bootstrap AOT
if which rlwrap > /dev/null && $TERM != "dumb" ; then java -cp "$CLASSPATH" clojure.main
rlwrap java -cp "$CLASSPATH" clojure.main
else
java -cp "$CLASSPATH" clojure.main
fi
else else
exec java -cp "$CLASSPATH" leiningen.core $@ exec java -cp "$CLASSPATH" leiningen.core $@
fi fi

View file

@ -14,4 +14,4 @@
(find-namespaces-in-dir (file (:root project) "src")))] (find-namespaces-in-dir (file (:root project) "src")))]
(println "Compiling" n) (println "Compiling" n)
;; TODO: check to see if bytecode is older than source ;; TODO: check to see if bytecode is older than source
(clojure.core/compile n)))) (clojure.core/compile n))))

View file

@ -6,6 +6,9 @@
(def project nil) (def project nil)
(defmacro defproject [project-name & args] (defmacro defproject [project-name & args]
;; This is necessary since we must allow defproject to be eval'd in
;; any namespace due to load-file; we can't just create a var with
;; def or we would not have access to it once load-file returned.
`(do (alter-var-root #'project `(do (alter-var-root #'project
(fn [_#] (assoc (apply hash-map (quote ~args)) (fn [_#] (assoc (apply hash-map (quote ~args))
:name ~(name project-name) :name ~(name project-name)
@ -15,10 +18,12 @@
(defn read-project (defn read-project
([file] (load-file file) ([file] (load-file file)
project) project)
([] (read-project "build.clj"))) ([] (read-project "project.clj")))
(defn -main [command & args] (defn -main [command & args]
(let [action (ns-resolve (symbol (str "leiningen." command)) (let [action (ns-resolve (symbol (str "leiningen." command))
(symbol command))] (symbol command))]
;; TODO: ensure tasks run only once ;; TODO: ensure tasks run only once
(apply action (read-project) args))) (apply action (read-project) args)
;; In case tests or some other task started any:
(shutdown-agents)))

View file

@ -4,7 +4,7 @@
[clojure.contrib.set] [clojure.contrib.set]
[clojure.contrib.java-utils :only [file delete-file-recursively]])) [clojure.contrib.java-utils :only [file delete-file-recursively]]))
(def test-project (read-project "test/build.clj")) (def test-project (read-project "test/project.clj"))
(deftest test-deps (deftest test-deps
(delete-file-recursively (file (:root test-project) "lib")) (delete-file-recursively (file (:root test-project) "lib"))