Merge branch 'master' into deb-etc

This commit is contained in:
Josh Suereth 2011-12-21 14:12:04 -05:00
commit 77c327de8c
2 changed files with 103 additions and 95 deletions

View File

@ -2,76 +2,57 @@ sbt: the rebel cut
==================
An alternative script for running [sbt](https://github.com/harrah/xsbt).
It works with sbt 0.7x projects as well as 0.10+. If you're in an sbt
project directory, the runner will figure out the versions of sbt
and scala required by the project and download them if necessary.
It works with sbt 0.7.x projects as well as 0.10+. If you're in an sbt
project directory, the runner will figure out the versions of sbt and
scala required by the project and download them if necessary.
There's also a template project sbt coming together, but it's unfinished.
See below for how to pull the template project in as a plugin.
However the runner is quite useful already.
Sample usage: create a new project using a snapshot version of sbt as
well as a snapshot version of scala, then run the sbt "about" command.
Here's a sample use of the runner: it creates a new project using a
snapshot version of sbt as well as a snapshot version of scala, then
runs the sbt "about" command.
% sbt -d -sbt-snapshot -210 -sbt-create about
% sbt -v -sbt-snapshot -210 -sbt-create about
Detected sbt version 0.11.3-SNAPSHOT
sbt snapshot is 0.11.3-20111207-052114
# Executing command line:
java
-Xss2m
-Xms256M
-Xmx1536M
-XX:MaxPermSize=256M
-XX:+CMSClassUnloadingEnabled
-XX:MaxPermSize=512m
-Xmx2g
-Xss2m
-Xms1536m
-Xmx1536m
-XX:MaxPermSize=384m
-XX:ReservedCodeCacheSize=192m
-Dfile.encoding=UTF8
-jar
/r/sbt-extras/.lib/0.11.0-20110825-052147/sbt-launch.jar
"set logLevel in Global := Level.Debug"
/r/sbt-extras/.lib/0.11.3-SNAPSHOT/sbt-launch.jar
"set resolvers in ThisBuild += ScalaToolsSnapshots"
"++ 2.10.0-SNAPSHOT"
"iflast shell"
about
Getting net.java.dev.jna jna 3.2.3 ...
:: retrieving :: org.scala-tools.sbt#boot-app
confs: [default]
1 artifacts copied, 0 already retrieved (838kB/12ms)
Getting Scala 2.9.1.RC4 (for sbt)...
:: retrieving :: org.scala-tools.sbt#boot-scala
confs: [default]
4 artifacts copied, 0 already retrieved (19939kB/32ms)
Getting org.scala-tools.sbt sbt_2.9.1.RC4 0.11.0-20110825-052147 ...
:: retrieving :: org.scala-tools.sbt#boot-app
confs: [default]
38 artifacts copied, 0 already retrieved (6948kB/45ms)
[info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/)
[info] Loading global plugins from /Users/paulp/.sbt/plugins
[info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/)
[info] Reapplying settings...
[info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/)
[info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/)
Setting version to 2.10.0-SNAPSHOT
[info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/)
Getting Scala 2.10.0-SNAPSHOT ...
:: retrieving :: org.scala-tools.sbt#boot-scala
confs: [default]
4 artifacts copied, 0 already retrieved (20650kB/58ms)
[info] This is sbt 0.11.0-20110825-052147
[info] The current project is {file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/}default-30ae78
[info] Set current project to default-71999b (in build file:/Users/paulp/Desktop/new/)
[info] This is sbt 0.11.3-20111207-052114
[info] The current project is {file:/Users/paulp/Desktop/new/}default-71999b
[info] The current project is built against Scala 2.10.0-SNAPSHOT
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.1.RC4
[info] All logging output for this session is available at /var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/sbt8625229869994477318.log
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.1
Current -help output:
Usage: sbt [options]
-h | -help print this message
-v | -verbose this runner is chattier
-d | -debug set sbt log level to debug
-no-colors disable ANSI color codes
-sbt-create start sbt even if current directory contains no sbt project
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
-h | -help print this message
-v | -verbose this runner is chattier
-d | -debug set sbt log level to debug
-no-colors disable ANSI color codes
-sbt-create start sbt even if current directory contains no sbt project
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
-mem <integer> set memory options (default: 1536, which is -Xms1536m -Xmx1536m -XX:MaxPermSize=384m -XX:ReservedCodeCacheSize=192m)
-no-share use all local caches; no sharing
-offline put sbt in offline mode
-jvm-debug <port> Turn on JVM debugging, open at the given port.
# sbt version (default: from project/build.properties if present, else latest release)
-sbt-version <version> use the specified version of sbt
@ -80,18 +61,18 @@ Current -help output:
-sbt-snapshot use a snapshot version of sbt
# scala version (default: latest release)
-28 use 2.8.1
-28 use 2.8.2
-29 use 2.9.1
-210 use 2.10.0-SNAPSHOT
-scala-home <path> use the scala build at the specified directory
-scala-version <version> use the specified version of scala
# java version (default: java from PATH, currently java version "1.6.0_26")
# java version (default: java from PATH, currently java version "1.6.0_29")
-java-home <path> alternate JAVA_HOME
# jvm options and output control
JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF8"
SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xms1536m -Xmx1536m -Xss2m"
SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled"
.sbtopts if this file exists in the sbt root, it is prepended to the runner args
-Dkey=val pass -Dkey=val directly to the java runtime
-J-X pass option -X directly to the java runtime (-J is stripped)
@ -99,7 +80,6 @@ Current -help output:
In the case of duplicated or conflicting options, the order above
shows precedence: JAVA_OPTS lowest, command line options highest.
## SBT Extra plugin
To see the plugin in action, including the thrilling custom sbt command "help-names":

104
sbt
View File

@ -75,6 +75,7 @@ unset verbose debug
# pull -J and -D options to give to java.
declare -a residual_args
declare -a java_args
declare -a scalac_args
declare -a sbt_commands
build_props_sbt () {
@ -118,9 +119,12 @@ execRunner () {
echoerr () {
echo 1>&2 "$@"
}
dlog () {
vlog () {
[[ $verbose || $debug ]] && echoerr "$@"
}
dlog () {
[[ $debug ]] && echoerr "$@"
}
sbtjar_07_url () {
echo "http://simple-build-tool.googlecode.com/files/sbt-launch-${1}.jar"
@ -214,17 +218,18 @@ usage () {
cat <<EOM
Usage: $script_name [options]
-h | -help print this message
-v | -verbose this runner is chattier
-d | -debug set sbt log level to debug
-no-colors disable ANSI color codes
-sbt-create start sbt even if current directory contains no sbt project
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
-mem <integer> set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem))
-no-share use all local caches; no sharing
-offline put sbt in offline mode
-h | -help print this message
-v | -verbose this runner is chattier
-d | -debug set sbt log level to debug
-no-colors disable ANSI color codes
-sbt-create start sbt even if current directory contains no sbt project
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
-mem <integer> set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem))
-no-share use all local caches; no sharing
-offline put sbt in offline mode
-jvm-debug <port> Turn on JVM debugging, open at the given port.
# sbt version (default: from project/build.properties if present, else latest release)
-sbt-version <version> use the specified version of sbt
@ -248,6 +253,7 @@ Usage: $script_name [options]
.sbtopts if this file exists in the sbt root, it is prepended to the runner args
-Dkey=val pass -Dkey=val directly to the java runtime
-J-X pass option -X directly to the java runtime (-J is stripped)
-S-X add -X to sbt's scalacOptions (-J is stripped)
In the case of duplicated or conflicting options, the order above
shows precedence: JAVA_OPTS lowest, command line options highest.
@ -262,6 +268,10 @@ addSbt () {
dlog "[addSbt] arg = '$1'"
sbt_commands=( "${sbt_commands[@]}" "$1" )
}
addScalac () {
dlog "[addScalac] arg = '$1'"
scalac_args=( "${scalac_args[@]}" "$1" )
}
addResidual () {
dlog "[residual] arg = '$1'"
residual_args=( "${residual_args[@]}" "$1" )
@ -269,44 +279,59 @@ addResidual () {
addResolver () {
addSbt "set resolvers in ThisBuild += $1"
}
unset addedSnapshotRepo
addSnapshotRepo () {
addResolver "ScalaToolsSnapshots"
[[ -n "$addedSnapshotRepo" ]] || addResolver "ScalaToolsSnapshots" && addedSnapshotRepo=true
}
addDebugger () {
addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"
}
process_args ()
{
require_arg () {
local type="$1"
local opt="$2"
local arg="$3"
if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then
die "$opt requires <$type> argument"
fi
}
while [[ $# -gt 0 ]]; do
case "$1" in
-h|-help) usage; exit 1 ;;
-v|-verbose) verbose=1; shift ;;
-d|-debug) debug=1; shift ;;
# -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload ; shift ;;
-v|-verbose) verbose=1 && shift ;;
-d|-debug) debug=1 && shift ;;
# -u|-upgrade) addSbt 'set sbt.version 0.7.7' ; addSbt reload && shift ;;
-ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;;
-mem) sbt_mem="$2"; shift 2 ;;
-no-colors) addJava "-Dsbt.log.noformat=true"; shift ;;
-no-share) addJava "$noshare_opts"; shift ;;
-sbt-boot) addJava "-Dsbt.boot.directory=$2"; shift 2 ;;
-sbt-dir) addJava "-Dsbt.global.base=$2"; shift 2 ;;
-debug-inc) addJava "-Dxsbt.inc.debug=true"; shift ;;
-offline) addSbt "set offline := true"; shift ;;
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
-mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;;
-no-colors) addJava "-Dsbt.log.noformat=true" && shift ;;
-no-share) addJava "$noshare_opts" && shift ;;
-sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
-sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;;
-debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
-offline) addSbt "set offline := true" && shift ;;
-jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
-sbt-create) sbt_create=true; shift ;;
-sbt-rc) [[ -n "$sbt_rc_version" ]] || die "no sbt RC candidate defined."; sbt_version=$sbt_rc_version; shift ;;
-sbt-snapshot) addSnapshotRepo ; sbt_version=$sbt_snapshot_version; shift ;;
-sbt-jar) sbt_jar="$2"; shift 2 ;;
-sbt-version) sbt_version="$2"; shift 2 ;;
-scala-version) addSbt "++ $2"; shift 2 ;;
-scala-home) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;;
-java-home) java_cmd="$2/bin/java"; shift 2 ;;
-sbt-create) sbt_create=true && shift ;;
-sbt-rc) [[ -n "$sbt_rc_version" ]] || die "no sbt RC candidate defined."; sbt_version=$sbt_rc_version && shift ;;
-sbt-snapshot) addSnapshotRepo ; sbt_version=$sbt_snapshot_version && shift ;;
-sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;;
-sbt-version) require_arg version "$1" "$2" && sbt_version="$2" && shift 2 ;;
-scala-version) require_arg version "$1" "$2" && addSbt "++ $2" && shift 2 ;;
-scala-home) require_arg path "$1" "$2" && addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))" && shift 2 ;;
-java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;;
-D*) addJava "$1"; shift ;;
-J*) addJava "${1:2}"; shift ;;
-28) addSbt "++ $latest_28"; shift ;;
-29) addSbt "++ $latest_29"; shift ;;
-210) addSnapshotRepo ; addSbt "++ $latest_210"; shift ;;
-D*) addJava "$1" && shift ;;
-J*) addJava "${1:2}" && shift ;;
-S*) addScalac "${1:2}" && shift ;;
-28) addSbt "++ $latest_28" && shift ;;
-29) addSbt "++ $latest_29" && shift ;;
-210) addSnapshotRepo ; addSbt "++ $latest_210" && shift ;;
*) addResidual "$1"; shift ;;
*) addResidual "$1" && shift ;;
esac
done
@ -331,6 +356,9 @@ process_args "$@"
set -- "${residual_args[@]}"
argumentCount=$#
# set scalacOptions if we were given any -S opts
[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\""
# figure out the version
[[ "$sbt_version" ]] || sbt_version=$(build_props_sbt)
[[ "$sbt_version" = *-SNAPSHOT* || "$sbt_version" = *-RC* ]] && sbt_snapshot=1