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
TODO: jar, uberjar, swank, new, help, deploy
TODO: jar, uberjar, swank, new, help, deploy, pom
## 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
: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
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
uses. See the file COPYING.

View file

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

View file

@ -6,6 +6,9 @@
(def project nil)
(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
(fn [_#] (assoc (apply hash-map (quote ~args))
:name ~(name project-name)
@ -15,10 +18,12 @@
(defn read-project
([file] (load-file file)
project)
([] (read-project "build.clj")))
([] (read-project "project.clj")))
(defn -main [command & args]
(let [action (ns-resolve (symbol (str "leiningen." command))
(symbol command))]
;; 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.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
(delete-file-recursively (file (:root test-project) "lib"))