mirror of https://github.com/sbt/sbt.git
More path/symlink issues, a few bugs which had crept in
in the hours since this project was founded, added an -sbtjar option.
This commit is contained in:
parent
d2477cbcdc
commit
8ff3e12a0e
|
|
@ -5,4 +5,4 @@ target
|
||||||
lib_managed
|
lib_managed
|
||||||
src_managed
|
src_managed
|
||||||
/ext
|
/ext
|
||||||
lib/sbt-launch.jar
|
.lib/sbt-launch.jar
|
||||||
|
|
@ -46,6 +46,7 @@ Current -help output:
|
||||||
-help prints this message
|
-help prints this message
|
||||||
-nocolor disable ANSI color codes
|
-nocolor disable ANSI color codes
|
||||||
-debug set sbt log level to debug
|
-debug set sbt log level to debug
|
||||||
|
-sbtjar <path> location of sbt launcher (default: ./.lib/sbt-launch.jar)
|
||||||
-sbtdir <path> location of global settings and plugins (default: ~/.sbt)
|
-sbtdir <path> location of global settings and plugins (default: ~/.sbt)
|
||||||
-ivy <path> local Ivy repository (default: ~/.ivy2)
|
-ivy <path> local Ivy repository (default: ~/.ivy2)
|
||||||
-shared <path> shared sbt boot directory (default: none, no sharing)
|
-shared <path> shared sbt boot directory (default: none, no sharing)
|
||||||
|
|
@ -66,4 +67,3 @@ Current -help output:
|
||||||
corresponding variable is unset. In the case of a duplicated option,
|
corresponding variable is unset. In the case of a duplicated option,
|
||||||
SBT_OPTS takes precedence over JAVA_OPTS, and command line options
|
SBT_OPTS takes precedence over JAVA_OPTS, and command line options
|
||||||
take precedence over both.
|
take precedence over both.
|
||||||
|
|
||||||
|
|
|
||||||
67
sbt
67
sbt
|
|
@ -9,35 +9,30 @@ set -e
|
||||||
launch_base=http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch
|
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
|
launch_url=$launch_base/0.10.1/sbt-launch.jar
|
||||||
|
|
||||||
declare -r script_dir="$(dirname $(readlink $BASH_SOURCE))"
|
# this seems to cover the bases on OSX, and someone will
|
||||||
declare -r script_name="$(basename $BASH_SOURCE)"
|
# have to tell me about the others.
|
||||||
declare -r sbt_jar="$script_dir/lib/sbt-launch.jar"
|
get_script_path () {
|
||||||
|
local path="$1"
|
||||||
|
[[ -L "$path" ]] || { echo "$path" ; return; }
|
||||||
|
|
||||||
|
local target=$(readlink "$path")
|
||||||
|
if [[ "${target:0:1}" == "/" ]]; then
|
||||||
|
echo "$target"
|
||||||
|
else
|
||||||
|
echo "$path/$target"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
declare -r script_path=$(get_script_path "$BASH_SOURCE")
|
||||||
|
declare -r script_dir="$(dirname $script_path)"
|
||||||
|
declare -r script_name="$(basename $script_path)"
|
||||||
|
declare -r default_sbt_jar="$script_dir/.lib/sbt-launch.jar"
|
||||||
declare -r default_java_opts="-Dfile.encoding=UTF8"
|
declare -r default_java_opts="-Dfile.encoding=UTF8"
|
||||||
declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m"
|
declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m"
|
||||||
declare -r latest_28="2.8.1"
|
declare -r latest_28="2.8.1"
|
||||||
declare -r latest_29="2.9.0-1"
|
declare -r latest_29="2.9.0-1"
|
||||||
declare -r latest_210="2.10.0-SNAPSHOT"
|
declare -r latest_210="2.10.0-SNAPSHOT"
|
||||||
|
|
||||||
# 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 () {
|
usage () {
|
||||||
cat <<EOM
|
cat <<EOM
|
||||||
Usage: $script_name [options]
|
Usage: $script_name [options]
|
||||||
|
|
@ -45,6 +40,7 @@ Usage: $script_name [options]
|
||||||
-help prints this message
|
-help prints this message
|
||||||
-nocolor disable ANSI color codes
|
-nocolor disable ANSI color codes
|
||||||
-debug set sbt log level to debug
|
-debug set sbt log level to debug
|
||||||
|
-sbtjar <path> location of sbt launcher (default: $default_sbt_jar)
|
||||||
-sbtdir <path> location of global settings and plugins (default: ~/.sbt)
|
-sbtdir <path> location of global settings and plugins (default: ~/.sbt)
|
||||||
-ivy <path> local Ivy repository (default: ~/.ivy2)
|
-ivy <path> local Ivy repository (default: ~/.ivy2)
|
||||||
-shared <path> shared sbt boot directory (default: none, no sharing)
|
-shared <path> shared sbt boot directory (default: none, no sharing)
|
||||||
|
|
@ -79,6 +75,8 @@ EOM
|
||||||
declare -a args
|
declare -a args
|
||||||
declare -a java_args
|
declare -a java_args
|
||||||
declare -a sbt_commands
|
declare -a sbt_commands
|
||||||
|
declare sbt_jar="$default_sbt_jar"
|
||||||
|
|
||||||
addJava () {
|
addJava () {
|
||||||
java_args=("${java_args[@]}" "$1")
|
java_args=("${java_args[@]}" "$1")
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +90,7 @@ while [ $# -gt 0 ]; do
|
||||||
|
|
||||||
-ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;;
|
-ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;;
|
||||||
-shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;;
|
-shared) addJava "-Dsbt.boot.directory=$2"; shift 2 ;;
|
||||||
-global) addJava "-Dsbt.global.base=$2"; shift 2 ;;
|
-sbtdir) addJava "-Dsbt.global.base=$2"; shift 2 ;;
|
||||||
-nocolors) addJava "-Dsbt.log.noformat=true"; shift ;;
|
-nocolors) addJava "-Dsbt.log.noformat=true"; shift ;;
|
||||||
-28) addJava "-Dsbt.scala.version=$latest_28"; shift ;;
|
-28) addJava "-Dsbt.scala.version=$latest_28"; shift ;;
|
||||||
-29) addJava "-Dsbt.scala.version=$latest_29"; shift ;;
|
-29) addJava "-Dsbt.scala.version=$latest_29"; shift ;;
|
||||||
|
|
@ -102,6 +100,7 @@ while [ $# -gt 0 ]; do
|
||||||
-J*) addJava "${1:2}"; shift ;;
|
-J*) addJava "${1:2}"; shift ;;
|
||||||
-debug) addSbt "set logLevel := Level.Debug"; debug=1; shift ;;
|
-debug) addSbt "set logLevel := Level.Debug"; debug=1; shift ;;
|
||||||
-local) addSbt "set scalaHome := Some(file(\"$2\"))"; shift 2 ;;
|
-local) addSbt "set scalaHome := Some(file(\"$2\"))"; shift 2 ;;
|
||||||
|
-sbtjar) sbt_jar="$2"; shift 2 ;;
|
||||||
|
|
||||||
*) args=("${args[@]}" "$1") ; shift ;;
|
*) args=("${args[@]}" "$1") ; shift ;;
|
||||||
esac
|
esac
|
||||||
|
|
@ -110,6 +109,26 @@ done
|
||||||
# reset "$@" to the residual args
|
# reset "$@" to the residual args
|
||||||
set -- "${args[@]}"
|
set -- "${args[@]}"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
execRunner () {
|
execRunner () {
|
||||||
# print the arguments one to a line, quoting any containing spaces
|
# print the arguments one to a line, quoting any containing spaces
|
||||||
(( debug )) && echo "# Executing command line:" && {
|
(( debug )) && echo "# Executing command line:" && {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue