mirror of https://github.com/sbt/sbt.git
Phoned in some tests. Updated the docs again.
This commit is contained in:
parent
221a049cc0
commit
01c75c8477
80
README.md
80
README.md
|
|
@ -1,14 +1,19 @@
|
||||||
sbt: the rebel cut
|
sbt: the rebel cut
|
||||||
==================
|
==================
|
||||||
|
|
||||||
An alternative script for running [sbt 0.10+](https://github.com/harrah/xsbt).
|
An alternative script for running [sbt](https://github.com/harrah/xsbt).
|
||||||
|
It works with sbt 0.7 projects as well as 0.10+. If you're in a directory
|
||||||
|
with an sbt project, you can just run it and it will use the right version
|
||||||
|
of sbt, including downloading sbt if necessary.
|
||||||
|
|
||||||
There's also a template project sbt coming together, but it's unfinished.
|
There's also a template project sbt coming together, but it's unfinished.
|
||||||
However the runner is quite useful already.
|
However the runner is quite useful already.
|
||||||
|
|
||||||
Here's a sample first run, which creates a new project using a snapshot
|
Here's a sample use of the runner: it creates a new project using a
|
||||||
version of sbt, and runs the sbt "about" command.
|
snapshot version of sbt as well as a snapshot version of scala, then
|
||||||
|
runs the sbt "about" command.
|
||||||
|
|
||||||
% sbt -debug -snapshot -create about
|
% sbt -d -sbt-snapshot -210 -sbt-create about
|
||||||
# Executing command line:
|
# Executing command line:
|
||||||
java
|
java
|
||||||
-Xss2m
|
-Xss2m
|
||||||
|
|
@ -22,29 +27,36 @@ version of sbt, and runs the sbt "about" command.
|
||||||
-jar
|
-jar
|
||||||
/r/sbt-extras/.lib/0.11.0-20110825-052147/sbt-launch.jar
|
/r/sbt-extras/.lib/0.11.0-20110825-052147/sbt-launch.jar
|
||||||
"set logLevel in Global := Level.Debug"
|
"set logLevel in Global := Level.Debug"
|
||||||
|
"++ 2.10.0-SNAPSHOT"
|
||||||
"iflast shell"
|
"iflast shell"
|
||||||
about
|
about
|
||||||
|
|
||||||
Getting net.java.dev.jna jna 3.2.3 ...
|
Getting net.java.dev.jna jna 3.2.3 ...
|
||||||
:: retrieving :: org.scala-tools.sbt#boot-app
|
:: retrieving :: org.scala-tools.sbt#boot-app
|
||||||
confs: [default]
|
confs: [default]
|
||||||
1 artifacts copied, 0 already retrieved (838kB/15ms)
|
1 artifacts copied, 0 already retrieved (838kB/12ms)
|
||||||
Getting Scala 2.9.1.RC4 (for sbt)...
|
Getting Scala 2.9.1.RC4 (for sbt)...
|
||||||
:: retrieving :: org.scala-tools.sbt#boot-scala
|
:: retrieving :: org.scala-tools.sbt#boot-scala
|
||||||
confs: [default]
|
confs: [default]
|
||||||
4 artifacts copied, 0 already retrieved (19939kB/97ms)
|
4 artifacts copied, 0 already retrieved (19939kB/32ms)
|
||||||
Getting org.scala-tools.sbt sbt_2.9.1.RC4 0.11.0-20110825-052147 ...
|
Getting org.scala-tools.sbt sbt_2.9.1.RC4 0.11.0-20110825-052147 ...
|
||||||
:: retrieving :: org.scala-tools.sbt#boot-app
|
:: retrieving :: org.scala-tools.sbt#boot-app
|
||||||
confs: [default]
|
confs: [default]
|
||||||
38 artifacts copied, 0 already retrieved (6948kB/71ms)
|
38 artifacts copied, 0 already retrieved (6948kB/45ms)
|
||||||
[info] Set current project to default-06d8dd (in build file:/private/tmp/sbt-project/)
|
[info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/)
|
||||||
[info] Reapplying settings...
|
[info] Reapplying settings...
|
||||||
[info] Set current project to default-06d8dd (in build file:/private/tmp/sbt-project/)
|
[info] Set current project to default-30ae78 (in build file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/)
|
||||||
|
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] This is sbt 0.11.0-20110825-052147
|
||||||
[info] The current project is {file:/private/tmp/sbt-project/}default-06d8dd
|
[info] The current project is {file:/private/var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/abc.h9FdreF1/}default-30ae78
|
||||||
[info] The current project is built against Scala 2.9.1.RC4
|
[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] 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/iO/iOpjflOpHzG8Mr1BL67D6k+++TI/-Tmp-/sbt75419762724938334.log
|
[info] All logging output for this session is available at /var/folders/1w/zm_1vksn3y7gn127bkwt841w0000gn/T/sbt8625229869994477318.log
|
||||||
|
|
||||||
|
|
||||||
Current -help output:
|
Current -help output:
|
||||||
|
|
@ -53,29 +65,37 @@ Current -help output:
|
||||||
|
|
||||||
Usage: sbt [options]
|
Usage: sbt [options]
|
||||||
|
|
||||||
-help prints this message
|
-h | -help print this message
|
||||||
-v | -verbose this runner is chattier
|
-v | -verbose this runner is chattier
|
||||||
-debug set sbt log level to debug
|
-d | -debug set sbt log level to debug
|
||||||
-nocolors disable ANSI color codes
|
-no-colors disable ANSI color codes
|
||||||
-create start sbt even in a directory with no project
|
-sbt-create start sbt even if current directory contains no sbt project
|
||||||
-sbtjar <path> location of sbt launcher (default: ./.lib/<sbt version>/sbt-launch.jar)
|
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
|
||||||
-sbtdir <path> location of global settings and plugins (default: ~/.sbt)
|
-sbt-boot <path> path to shared boot directory (default: none, no sharing)
|
||||||
-ivy <path> local Ivy repository (default: ~/.ivy2)
|
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
|
||||||
-shared <path> shared sbt boot directory (default: none, no sharing)
|
|
||||||
|
|
||||||
# setting scala and sbt versions
|
# sbt version (default: from project/build.properties if there, else latest release)
|
||||||
-28 set scala version to 2.8.2.RC1
|
-sbt-version <version> use the specified version of sbt
|
||||||
-29 set scala version to 2.9.1.RC4
|
-sbt-jar <path> use the specified jar as the sbt launcher
|
||||||
-210 set scala version to 2.10.0-SNAPSHOT
|
-sbt-snapshot use a snapshot version of sbt
|
||||||
-local <path> set scala version to local installation at path
|
|
||||||
-snapshot use a snapshot of sbt (otherwise, latest released version)
|
# scala version (default: latest release)
|
||||||
|
-28 use 2.8.1
|
||||||
|
-29 use 2.9.0-1
|
||||||
|
-29rc use 2.9.1.RC4
|
||||||
|
-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-home <path> alternate JAVA_HOME
|
||||||
|
|
||||||
# jvm options and output control
|
# jvm options and output control
|
||||||
JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF8"
|
JAVA_OPTS environment variable, if unset uses "-Dfile.encoding=UTF8"
|
||||||
SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m"
|
SBT_OPTS environment variable, if unset uses "-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512m -Xmx2g -Xss2m"
|
||||||
.sbtopts file in sbt root directory, if present contents passed to sbt
|
.sbtopts if this file exists in the sbt root, it is prepended to the runner args
|
||||||
-Dkey=val pass -Dkey=val directly to the jvm
|
-Dkey=val pass -Dkey=val directly to the java runtime
|
||||||
-J-X pass option -X directly to the jvm (-J is stripped)
|
-J-X pass option -X directly to the java runtime (-J is stripped)
|
||||||
|
|
||||||
In the case of duplicated or conflicting options, the order above
|
In the case of duplicated or conflicting options, the order above
|
||||||
shows precedence: JAVA_OPTS lowest, command line options highest.
|
shows precedence: JAVA_OPTS lowest, command line options highest.
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,9 @@ class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build {
|
||||||
|
|
||||||
lazy val testSettings = Seq(
|
lazy val testSettings = Seq(
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"org.specs2" %% "specs2" % "1.5",
|
"org.scala-tools.testing" % "specs_2.9.0-1" % "1.6.8" % "test"
|
||||||
"org.specs2" %% "specs2-scalaz-core" % "6.0.RC2" % "test"
|
),
|
||||||
)
|
libraryDependencies <+= (scalaVersion)(v => "org.scala-lang" % "scala-compiler" % v)
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val buildSettings = Seq(
|
lazy val buildSettings = Seq(
|
||||||
|
|
@ -105,7 +105,7 @@ class TemplateBuild(implicit sbtCreateConfig: SbtCreateConfig) extends Build {
|
||||||
aggregate = Nil,
|
aggregate = Nil,
|
||||||
dependencies = Nil,
|
dependencies = Nil,
|
||||||
delegates = Nil,
|
delegates = Nil,
|
||||||
settings = Defaults.defaultSettings ++ buildSettings ++ Seq(
|
settings = Defaults.defaultSettings ++ buildSettings ++ testSettings ++ Seq(
|
||||||
commands += helpNames
|
commands += helpNames
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
22
sbt
22
sbt
|
|
@ -89,12 +89,12 @@ Usage: $script_name [options]
|
||||||
|
|
||||||
-h | -help print this message
|
-h | -help print this message
|
||||||
-v | -verbose this runner is chattier
|
-v | -verbose this runner is chattier
|
||||||
-debug set sbt log level to debug
|
-d | -debug set sbt log level to debug
|
||||||
-no-colors disable ANSI color codes
|
-no-colors disable ANSI color codes
|
||||||
-sbt-create start sbt even if location has no sbt project
|
-sbt-create start sbt even if current directory contains no sbt project
|
||||||
-sbt-dir <path> location of global settings and plugins (default: ~/.sbt)
|
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
|
||||||
-sbt-boot <path> shared sbt boot directory (default: none, no sharing)
|
-sbt-boot <path> path to shared boot directory (default: none, no sharing)
|
||||||
-ivy <path> local Ivy repository (default: ~/.ivy2)
|
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
|
||||||
|
|
||||||
# sbt version (default: from project/build.properties if there, else latest release)
|
# sbt version (default: from project/build.properties if there, else latest release)
|
||||||
-sbt-version <version> use the specified version of sbt
|
-sbt-version <version> use the specified version of sbt
|
||||||
|
|
@ -109,13 +109,13 @@ Usage: $script_name [options]
|
||||||
-scala-home <path> use the scala build at the specified directory
|
-scala-home <path> use the scala build at the specified directory
|
||||||
-scala-version <version> use the specified version of scala
|
-scala-version <version> use the specified version of scala
|
||||||
|
|
||||||
# java version (default: $(which java))
|
# java version (default: java from PATH, currently $(java -version |& grep version))
|
||||||
-java-home <path> use specified path as JAVA_HOME
|
-java-home <path> alternate JAVA_HOME
|
||||||
|
|
||||||
# jvm options and output control
|
# jvm options and output control
|
||||||
JAVA_OPTS environment variable, if unset uses "$default_java_opts"
|
JAVA_OPTS environment variable, if unset uses "$default_java_opts"
|
||||||
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
|
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
|
||||||
.sbtopts if this file is in the sbt root directory, its contents are arguments
|
.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
|
-Dkey=val pass -Dkey=val directly to the java runtime
|
||||||
-J-X pass option -X directly to the java runtime (-J is stripped)
|
-J-X pass option -X directly to the java runtime (-J is stripped)
|
||||||
|
|
||||||
|
|
@ -141,7 +141,8 @@ process_args ()
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h|-help) usage; exit 1 ;;
|
-h|-help) usage; exit 1 ;;
|
||||||
-v|-verbose) verbose=1 ; shift ;;
|
-v|-verbose) verbose=1; shift ;;
|
||||||
|
-d|-debug) debug=1; addSbt "set logLevel in Global := Level.Debug"; shift ;;
|
||||||
|
|
||||||
-ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;;
|
-ivy) addJava "-Dsbt.ivy.home=$2"; shift 2 ;;
|
||||||
-no-colors) addJava "-Dsbt.log.noformat=true"; shift ;;
|
-no-colors) addJava "-Dsbt.log.noformat=true"; shift ;;
|
||||||
|
|
@ -152,7 +153,7 @@ process_args ()
|
||||||
-sbt-snapshot) sbt_snapshot=1; shift ;;
|
-sbt-snapshot) sbt_snapshot=1; shift ;;
|
||||||
-sbt-jar) sbt_jar="$2"; shift 2 ;;
|
-sbt-jar) sbt_jar="$2"; shift 2 ;;
|
||||||
-sbt-version) sbt_version="$2"; shift 2 ;;
|
-sbt-version) sbt_version="$2"; shift 2 ;;
|
||||||
-scala-version) scala_version="$2"; shift 2 ;;
|
-scala-version) addSbt "++ $2"; shift 2 ;;
|
||||||
-scala-home) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;;
|
-scala-home) addSbt "set scalaHome in ThisBuild := Some(file(\"$2\"))"; shift 2 ;;
|
||||||
-java-home) java_cmd="$2/bin/java"; shift 2 ;;
|
-java-home) java_cmd="$2/bin/java"; shift 2 ;;
|
||||||
|
|
||||||
|
|
@ -162,7 +163,6 @@ process_args ()
|
||||||
-29) addSbt "++ $latest_29"; shift ;;
|
-29) addSbt "++ $latest_29"; shift ;;
|
||||||
-29rc) addSbt "++ $latest_29rc"; shift ;;
|
-29rc) addSbt "++ $latest_29rc"; shift ;;
|
||||||
-210) addSbt "++ $latest_210"; shift ;;
|
-210) addSbt "++ $latest_210"; shift ;;
|
||||||
-debug) addSbt "set logLevel in Global := Level.Debug"; debug=1; shift ;;
|
|
||||||
|
|
||||||
*) args=("${args[@]}" "$1") ; shift ;;
|
*) args=("${args[@]}" "$1") ; shift ;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package org.improving
|
||||||
|
|
||||||
|
import scala.tools.nsc.io._
|
||||||
|
import org.specs._
|
||||||
|
|
||||||
|
object SbtRunnerTest extends Specification {
|
||||||
|
val scripts = {
|
||||||
|
import Predef._
|
||||||
|
List[String](
|
||||||
|
"""|sbt -sbt-create -sbt-snapshot -210
|
||||||
|
|sbt update
|
||||||
|
|sbt about
|
||||||
|
""",
|
||||||
|
"""|sbt -sbt-create -sbt-snapshot -29
|
||||||
|
|sbt update
|
||||||
|
|sbt version
|
||||||
|
""",
|
||||||
|
"""|sbt -sbt-create -sbt-version 0.7.7 -28
|
||||||
|
|sbt help
|
||||||
|
|sbt -h
|
||||||
|
"""
|
||||||
|
) map (_.trim.stripMargin.lines.toList)
|
||||||
|
}
|
||||||
|
|
||||||
|
val singles = """
|
||||||
|
sbt -v -d -no-colors update package
|
||||||
|
sbt -verbose -210 -debug -ivy /tmp update
|
||||||
|
""".trim.lines
|
||||||
|
|
||||||
|
import scala.sys.process._
|
||||||
|
|
||||||
|
def sbtProjectLines(lines: List[String]) = {
|
||||||
|
println("Running: " + lines.mkString(", "))
|
||||||
|
|
||||||
|
val dir = Directory.makeTemp("sbt-runner-test").jfile
|
||||||
|
val result = lines map (x => Process(x, dir)) reduceLeft (_ #&& _) ! ;
|
||||||
|
|
||||||
|
result == 0
|
||||||
|
}
|
||||||
|
def sbtProjectLine(line: String) =
|
||||||
|
sbtProjectLines(List("sbt -sbt-create version", line))
|
||||||
|
|
||||||
|
"Sbt Runner" should {
|
||||||
|
"deal with lots of different command lines" in {
|
||||||
|
singles foreach (x => sbtProjectLine(x) mustEqual true)
|
||||||
|
}
|
||||||
|
"handle various command sequences" in {
|
||||||
|
scripts foreach (xs => sbtProjectLines(xs) mustEqual true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue