leiningen/bin/lein

56 lines
1.5 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 \:)"
CLASSPATH="src/:classes/:$LIBS"
LEIN_JAR=$HOME/.m2/repository/leiningen/leiningen/0.5.0-SNAPSHOT/leiningen-0.5.0-SNAPSHOT.jar
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
if [ ! -r "bin/lein" ]; then
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
if [ "$1" = "test" ]; then
CLASSPATH=test/:$CLASSPATH
fi
2009-11-10 06:22:09 +00:00
if [ $DEBUG ]; then
echo $CLASSPATH
fi
# 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
$0 deps
fi
fi
if [ "$1" = "repl" ]; then
# If repl used leiningen.core then there'd be no way to bootstrap AOT
java -cp "$CLASSPATH" clojure.main
elif [ "$1" = "self-install" ]; then
2009-11-10 06:22:09 +00:00
echo "Downloading Leiningen now..."
mkdir -p `dirname "$LEIN_JAR"`
2009-11-10 06:22:09 +00:00
LEIN_URL=http://repo.technomancy.us/leiningen.jar
if type -p curl >/dev/null 2>&1; then
exec curl -o "$LEIN_JAR" "$LEIN_URL"
2009-11-10 06:22:09 +00:00
else
exec wget -O "$LEIN_JAR" "$LEIN_URL"
2009-11-10 06:22:09 +00:00
fi
else
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 $@
fi
fi