~ better ./sbt script (works with curl and wget)
authorAlexandre Bertails <bertails@gmail.com>
Sun, 02 Oct 2011 18:19:45 -0400
changeset 39 3f2d3842819e
parent 38 38367717b140
child 40 8562e8b7d113
~ better ./sbt script (works with curl and wget)
.hgignore
sbt
--- a/.hgignore	Wed Sep 28 13:44:48 2011 -0400
+++ b/.hgignore	Sun Oct 02 18:19:45 2011 -0400
@@ -13,5 +13,6 @@
 *\#
 src/main/scala.egp
 src/test/scala.egp
-sbt-launch.jar
-.scala_dependencies
\ No newline at end of file
+sbt-launch*.jar
+.scala_dependencies
+*.orig
\ No newline at end of file
--- a/sbt	Wed Sep 28 13:44:48 2011 -0400
+++ b/sbt	Sun Oct 02 18:19:45 2011 -0400
@@ -3,9 +3,40 @@
 dir=$(dirname $0)
 cd "$dir"
 
-if [ ! -f sbt-launch.jar ]; then
-    wget http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/0.10.1/sbt-launch.jar
+url="http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/0.11.0/sbt-launch.jar"
+
+sbt="sbt-launch-0.11.0.jar"
+
+# set the right tool to download sbt
+if [ -n "$tool" ]; then
+    echo -n
+elif [ -n "$(which wget)" ]; then
+    tool="wget"
+elif [ -n "$(which curl)" ]; then
+    tool="curl"
+else
+    echo "Couldn't find a tool to download sbt. Please do the following"
+    echo "* download $url"
+    echo "* set the name of the file to $sbt"
+    echo "* relaunch ./sbt"
+    exit 1
 fi
 
-java -Xmx512M -jar -Dfile.encoding=UTF8 -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m "$dir/sbt-launch.jar" "[email protected]"
+# download the sbt launcher if it's not already here
+if [ ! -f "$sbt" ]; then
+    case "$tool" in
+        "wget"*)
+            wget "$url" -O "./$sbt"
+            ;;
+        "curl"*)
+            curl "$url" -o "./$sbt"
+            ;;
+        *)
+            echo "don't know this tool: $tool"
+            exit 2
+    esac
+fi
 
+# tweak this line according to your needs
+java -Xmx512M -jar -Dfile.encoding=UTF8 -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m "$dir/$sbt" "[email protected]"
+