2009-11-02 06:21:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2009-11-12 05:24:48 +00:00
|
|
|
# TODO: this gives us a trailing colon
|
2009-11-18 07:10:25 +00:00
|
|
|
VERSION=0.5.0
|
2009-11-10 06:22:09 +00:00
|
|
|
LIBS="$(find -H lib/ -mindepth 2> /dev/null 1 -maxdepth 1 -print0 | tr \\0 \:)"
|
2009-11-06 04:36:27 +00:00
|
|
|
CLASSPATH="src/:classes/:$LIBS"
|
2009-11-18 07:10:25 +00:00
|
|
|
LEIN_JAR=$HOME/.m2/repository/leiningen/leiningen/$VERSION/leiningen-$VERSION.jar
|
2009-11-06 04:36:27 +00:00
|
|
|
|
2009-11-17 04:05:07 +00:00
|
|
|
# this needs to exist before the JVM is launched apparently
|
|
|
|
mkdir -p classes
|
|
|
|
|
2009-11-12 05:24:48 +00:00
|
|
|
# If we are not running from a checkout
|
2009-11-06 04:36:27 +00:00
|
|
|
if [ ! -r "bin/lein" ]; then
|
2009-11-14 21:44:59 +00:00
|
|
|
if [ ! -r "$LEIN_JAR" -a "$1" != "self-install" ]; then
|
2009-11-12 05:24:48 +00:00
|
|
|
echo "Leiningen is not installed. Please run \"lein self-install\"."
|
|
|
|
exit 1
|
2009-11-10 06:22:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
CLASSPATH="$CLASSPATH:$LEIN_JAR"
|
2009-11-02 06:21:50 +00:00
|
|
|
fi
|
|
|
|
|
2009-11-14 21:44:59 +00:00
|
|
|
if [ "$1" = "test" ]; then
|
2009-11-02 06:47:41 +00:00
|
|
|
CLASSPATH=test/:$CLASSPATH
|
2009-11-02 06:38:59 +00:00
|
|
|
fi
|
|
|
|
|
2009-11-10 06:22:09 +00:00
|
|
|
if [ $DEBUG ]; then
|
|
|
|
echo $CLASSPATH
|
|
|
|
fi
|
|
|
|
|
2009-11-18 06:03:12 +00:00
|
|
|
# Deps need to run before the JVM launches for tasks that need them
|
|
|
|
if [ "$1" = "compile" -o "$1" = "jar" -o "$1" = "uberjar" ]; then
|
|
|
|
if [ ! "$(ls -A lib/*jar 2> /dev/null)" ]; then
|
2009-11-18 07:04:13 +00:00
|
|
|
$0 deps skip-dev
|
2009-11-18 06:03:12 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2009-11-14 21:44:59 +00:00
|
|
|
if [ "$1" = "repl" ]; then
|
2009-11-06 04:36:27 +00:00
|
|
|
# If repl used leiningen.core then there'd be no way to bootstrap AOT
|
|
|
|
java -cp "$CLASSPATH" clojure.main
|
2009-11-14 21:44:59 +00:00
|
|
|
elif [ "$1" = "self-install" ]; then
|
2009-11-10 06:22:09 +00:00
|
|
|
echo "Downloading Leiningen now..."
|
2009-11-18 06:03:12 +00:00
|
|
|
mkdir -p `dirname "$LEIN_JAR"`
|
2009-11-18 07:10:25 +00:00
|
|
|
LEIN_URL=http://repo.technomancy.us/leiningen-$VERSION.jar
|
2009-11-15 08:00:45 +00:00
|
|
|
if type -p curl >/dev/null 2>&1; then
|
2009-11-18 06:03:12 +00:00
|
|
|
exec curl -o "$LEIN_JAR" "$LEIN_URL"
|
2009-11-10 06:22:09 +00:00
|
|
|
else
|
2009-11-18 06:03:12 +00:00
|
|
|
exec wget -O "$LEIN_JAR" "$LEIN_URL"
|
2009-11-10 06:22:09 +00:00
|
|
|
fi
|
2009-11-02 06:38:59 +00:00
|
|
|
else
|
2009-11-14 23:03:09 +00:00
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "$0 missing task"
|
|
|
|
echo "Usage: $0 taskname"
|
|
|
|
else
|
2009-11-14 23:42:44 +00:00
|
|
|
exec java -client -cp "$CLASSPATH" leiningen.core $@
|
2009-11-14 23:03:09 +00:00
|
|
|
fi
|
2009-11-02 06:38:59 +00:00
|
|
|
fi
|