Permalink
Browse files

Updated various bits for sbt 0.12, plus -trace and -prompt.

 -trace: set the stack trace level
-prompt: set the sbt prompt
  • Loading branch information...
1 parent 22953b7 commit 35ad78ce1533074a590bba5b150de036a12e323b @paulp committed Nov 5, 2012
Showing with 39 additions and 29 deletions.
  1. +21 −8 README.md
  2. +18 −21 sbt
View
@@ -46,6 +46,14 @@ well as a snapshot version of scala, then run the sbt "about" command.
[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
+Sample, contrived usage of `prompt` option, using both `e` and `s`:
+
+ % sbt -prompt 'e.evalTask(Keys.scalacOptions, s) + "> "'
+ [info] <snip>
+ List(-deprecation)> set scalacOptions += "-Xlint"
+ [info] <snip>
+ List(-deprecation, -Xlint)>
+
Current -help output:
Usage: sbt [options]
@@ -54,31 +62,36 @@ Current -help output:
-v | -verbose this runner is chattier
-d | -debug set sbt log level to Debug
-q | -quiet set sbt log level to Error
+ -trace <level> display stack traces with a max of <level> frames (default: 15)
-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/<version>)
- -sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
+ -sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11+)
-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)
+ -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.
-batch Disable interactive mode
+ -prompt <expr> Set the sbt prompt; in expr, 's' is the State and 'e' is Extracted
# sbt version (default: from project/build.properties if present, else latest release)
+ !!! The only way to accomplish this pre-0.12.0 if there is a build.properties file which
+ !!! contains an sbt.version property is to update the file on disk. That's what this does.
-sbt-version <version> use the specified version of sbt
-sbt-jar <path> use the specified jar as the sbt launcher
- -sbt-rc use an RC version of sbt
-sbt-snapshot use a snapshot version of sbt
+ -sbt-launch-dir <path> directory to hold sbt launchers (default: ./.lib)
- # scala version (default: latest release)
+ # scala version (default: as chosen by sbt)
-28 use 2.8.2
- -29 use 2.9.1
- -210 use 2.10.0-SNAPSHOT
+ -29 use 2.9.2
+ -210 use 2.10.0-RC2
-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_29")
+ # java version (default: java from PATH, currently java version "1.7.0_06")
-java-home <path> alternate JAVA_HOME
# jvm options and output control
@@ -98,7 +111,7 @@ Current -help output:
To see the plugin in action, including the thrilling custom sbt command "help-names":
cd template-project && ../sbt -sbt-rc help-names zomg zomg2
-
+
The template files are:
project/plugins/project/Build.scala # you can use this as-is if you want
View
39 sbt
@@ -9,7 +9,7 @@ declare -r sbt_snapshot_version=0.13.0-SNAPSHOT
unset sbt_jar sbt_dir sbt_create sbt_snapshot sbt_launch_dir
unset scala_version java_home sbt_explicit_version
-unset verbose debug quiet noshare
+unset verbose debug quiet noshare trace_level log_level
for arg in "$@"; do
case $arg in
@@ -108,12 +108,13 @@ make_url () {
declare -r default_jvm_opts="-Dfile.encoding=UTF8"
declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled"
declare -r default_sbt_mem=1536
+declare -r default_trace_level=15
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
declare -r sbt_opts_file=".sbtopts"
declare -r jvm_opts_file=".jvmopts"
declare -r latest_28="2.8.2"
declare -r latest_29="2.9.2"
-declare -r latest_210="2.10.0-SNAPSHOT"
+declare -r latest_210="2.10.0-RC2"
declare -r script_path=$(get_script_path "$BASH_SOURCE")
declare -r script_dir="$(dirname $script_path)"
@@ -125,6 +126,8 @@ declare sbt_launch_dir="$script_dir/.lib"
declare sbt_universal_launcher="$script_dir/lib/sbt-launch.jar"
declare sbt_mem=$default_sbt_mem
declare sbt_jar=$sbt_universal_launcher
+declare trace_level=$default_trace_level
+declare log_level=Info
# pull -J and -D options to give to java.
declare -a residual_args
@@ -241,6 +244,7 @@ Usage: $script_name [options]
-v | -verbose this runner is chattier
-d | -debug set sbt log level to Debug
-q | -quiet set sbt log level to Error
+ -trace <level> display stack traces with a max of <level> frames (default: $default_trace_level)
-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/<version>)
@@ -252,6 +256,7 @@ Usage: $script_name [options]
-offline put sbt in offline mode
-jvm-debug <port> Turn on JVM debugging, open at the given port.
-batch Disable interactive mode
+ -prompt <expr> Set the sbt prompt; in expr, 's' is the State and 'e' is Extracted
# sbt version (default: from project/build.properties if present, else latest release)
!!! The only way to accomplish this pre-0.12.0 if there is a build.properties file which
@@ -302,7 +307,7 @@ addResidual () {
residual_args=( "${residual_args[@]}" "$1" )
}
addResolver () {
- addSbt "set resolvers in ThisBuild += $1"
+ addSbt "set every resolvers += $1"
}
addDebugger () {
addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"
@@ -329,9 +334,10 @@ process_args ()
case "$1" in
-h|-help) usage; exit 1 ;;
-v|-verbose) verbose=1 && shift ;;
- -d|-debug) debug=1 && shift ;;
- -q|-quiet) quiet=1 && shift ;;
+ -d|-debug) debug=1 && log_level=Debug && shift ;;
+ -q|-quiet) quiet=1 && log_level=Error && shift ;;
+ -trace) require_arg integer "$1" "$2" && trace_level=$2 && shift 2 ;;
-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 ;;
@@ -342,14 +348,15 @@ process_args ()
-offline) addSbt "set offline := true" && shift ;;
-jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
-batch) exec </dev/null && shift ;;
+ -prompt) require_arg "expr" "$1" "$2" && addSbt "set shellPrompt in ThisBuild := (s => { val e = Project.extract(s) ; $2 })" && shift 2 ;;
-sbt-create) sbt_create=true && shift ;;
-sbt-snapshot) sbt_explicit_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_explicit_version="$2" && shift 2 ;;
-sbt-launch-dir) require_arg path "$1" "$2" && sbt_launch_dir="$2" && shift 2 ;;
- -scala-version) require_arg version "$1" "$2" && addSbt "set scalaVersion := \"$2\"" && shift 2 ;;
- -scala-home) require_arg path "$1" "$2" && addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))" && shift 2 ;;
+ -scala-version) require_arg version "$1" "$2" && addSbt "set every scalaVersion := \"$2\"" && addSbt "set every scalaBinaryVersion := \"$2\"" && shift 2 ;;
+ -scala-home) require_arg path "$1" "$2" && addSbt "set every scalaHome := Some(file(\"$2\"))" && shift 2 ;;
-java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;;
-D*) addJava "$1" && shift ;;
@@ -362,19 +369,6 @@ process_args ()
*) addResidual "$1" && shift ;;
esac
done
-
- [[ $debug ]] && {
- case $(sbt_version) in
- 0.7.*) addSbt "debug" ;;
- *) addSbt "set logLevel in Global := Level.Debug" ;;
- esac
- }
- [[ $quiet ]] && {
- case $(sbt_version) in
- 0.7.*) ;;
- *) addSbt "set logLevel in Global := Level.Error" ;;
- esac
- }
}
# if .sbtopts exists, prepend its contents to $@ so it can be processed by this runner
@@ -393,7 +387,7 @@ set -- "${residual_args[@]}"
argumentCount=$#
# set scalacOptions if we were given any -S opts
-[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set scalacOptions in ThisBuild += \"${scalac_args[@]}\""
+[[ ${#scalac_args[@]} -eq 0 ]] || addSbt "set every scalacOptions += \"${scalac_args[@]}\""
# Update build.properties no disk to set explicit version - sbt gives us no choice
[[ -n "$sbt_explicit_version" ]] && update_build_props_sbt "$sbt_explicit_version"
@@ -444,5 +438,8 @@ execRunner "$java_cmd" \
$(get_jvm_opts) \
${java_args[@]} \
-jar "$sbt_jar" \
+ -shell \
+ "set logLevel in Global := Level.$log_level" \
+ "set every traceLevel := $trace_level" \
"${sbt_commands[@]}" \
"${residual_args[@]}"

0 comments on commit 35ad78c

Please sign in to comment.