diff --git a/.gitignore b/.gitignore index 721cc4e..01c53bb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ target lib_managed src_managed /ext +lib/sbt-launch.jar \ No newline at end of file diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..46e4a96 --- /dev/null +++ b/lib/README @@ -0,0 +1 @@ +sbt-launch.jar to be downloaded into here. \ No newline at end of file diff --git a/sbt b/sbt index b0124b8..12851eb 100755 --- a/sbt +++ b/sbt @@ -5,44 +5,66 @@ set -e +# todo - make this dynamic +launch_base=http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch +launch_url=$launch_base/0.10.1/sbt-launch.jar + +declare -r script_dir=$(cd $(dirname $BASH_SOURCE) ; pwd) declare -r script_name="$(basename $BASH_SOURCE)" -declare -r sbt_jar=/soft/inst/sbt/xsbt-launch.jar +declare -r sbt_jar="$script_dir/lib/sbt-launch.jar" declare -r default_java_opts="-Dfile.encoding=UTF8" declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m" declare -r latest_28="2.8.1" declare -r latest_29="2.9.0-1" declare -r latest_210="2.10.0-SNAPSHOT" -# pick up completion if present +# pick up completion if present; todo [[ -f .sbt_completion.sh ]] && source .sbt_completion.sh +# no jar? download it. +[[ -f "$sbt_jar" ]] || { + echo "Downloading sbt launcher, this should only take a moment..." + + if which curl >/dev/null; then + curl "$launch_url" --output "$sbt_jar" + elif which wget >/dev/null; then + wget "$launch_url" > "$sbt_jar" + fi +} + +# still no jar? uh-oh. +[[ -f "$sbt_jar" ]] || { + echo "Download failed. Obtain the jar manually and place it at $sbt_jar" + exit 1 +} + usage () { cat < location of global settings and plugins (default: ~/.sbt) + -ivy local Ivy repository (default: ~/.ivy2) + -shared shared sbt boot directory (default: none, no sharing) + + # setting scala version + -28 set scala version to $latest_28 + -29 set scala version to $latest_29 + -210 set scala version to $latest_210 + -local set scala version to local installation at path + + # passing options to jvm + JAVA_OPTS environment variable # default: "$default_java_opts" + SBT_OPTS environment variable # default: "$default_sbt_opts" + -Dkey=val pass -Dkey=val directly to the jvm + -J-X pass option -X directly to the jvm (-J is stripped) + +The defaults list for JAVA_OPTS and SBT_OPTS are only given if the +corresponding variable is unset. In the case of a duplicated option, +SBT_OPTS takes precedence over JAVA_OPTS, and command line options +take precedence over both. EOM }