leiningen/bin/lein

46 lines
1.2 KiB
Text
Raw Normal View History

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-10 06:22:09 +00:00
LIBS="$(find -H lib/ -mindepth 2> /dev/null 1 -maxdepth 1 -print0 | tr \\0 \:)"
2009-11-12 05:24:48 +00:00
# TODO: older versions of clojure in lib/ break leiningen
CLASSPATH="src/:classes/:$LIBS"
2009-11-12 05:24:48 +00:00
LEIN_JAR=$HOME/.leiningen.jar
2009-11-12 05:24:48 +00:00
# If we are not running from a checkout
if [ ! -r "bin/lein" ]; then
2009-11-12 05:24:48 +00:00
if [ ! -r "$LEIN_JAR" -a $1 != "self-install" ]; then
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
if [ $1 = "test" ]; then
CLASSPATH=test/:$CLASSPATH
fi
2009-11-12 05:24:48 +00:00
if [ $1 = "compile" ]; then
# this needs to exist before the JVM is launched apparently
mkdir -p classes
fi
2009-11-10 06:22:09 +00:00
if [ $DEBUG ]; then
echo $CLASSPATH
fi
if [ $1 = "repl" ]; then
# If repl used leiningen.core then there'd be no way to bootstrap AOT
java -cp "$CLASSPATH" clojure.main
2009-11-10 06:22:09 +00:00
elif [ $1 = "self-install" ]; then
echo "Downloading Leiningen now..."
LEIN_URL=http://repo.technomancy.us/leiningen.jar
if [ -x curl ]; then
exec curl -o $LEIN_JAR $LEIN_URL
else
exec wget -O $LEIN_JAR $LEIN_URL
fi
else
exec java -cp "$CLASSPATH" leiningen.core $@
fi