sbt's model is immutable
val scalaVersion: SettingKey[String]
val scalacOptions: TaskKey[Seq[String]]
val libraryDependencies: SettingKey[Seq[ModuleID]]
val compile: TaskKey[Analysis]
val test: TaskKey[Unit]
scalacOptions in ( Compile, doc ) := Seq.empty
publishArtifact in Test := false
scalacOptions
in compile and test
> inspect test:scalacOptions
[info] Task: scala.collection.Seq[java.lang.String]
[info] Description:
[info] Options for the Scala compiler.
...
[info] Delegates:
[info] my-project/test:scalacOptions
[info] my-project/runtime:scalacOptions
[info] my-project/compile:scalacOptions
[info] my-project/*:scalacOptions
[info] {.}/test:scalacOptions
...
Each setting or task can depend on another. For example:
libraryDependencies <+= // The '<' prefix denotes a dependency
scalaVersion( "org.scala-lang" % "scala-reflect" % _ % "provided" )
A dependency is implicitly created:
inspect libraryDependencies
[info] Setting: scala.collection.Seq[sbt.ModuleID] = List(org.scala-lang:scala-library:2.10.3, org.scala-lang:scala-reflect:2.10.3:provided, org.scalatest:scalatest:2.0:test)
[info] Description:
[info] Declares managed dependencies.
...
[info] Dependencies:
[info] my-project/*:scalaVersion
[info] Reverse dependencies:
[info] my-project/*:allDependencies
...
lazy val common = Project in file( "common" )
lazy val model = Project in file( "model" ) dependsOn( common )
lazy val webapp = Project in file( "webapp" ) dependsOn( common, model )
lazy val root = Project in file( "." ) aggregate( common, model, webapp )
project/<file>.scala
<file>.sbt
<project>/lib
libraryDependencies
%
%%
helper for Scala dependencies
libraryDependencies ++= Seq(
"org.springframework" % "spring-context" % "3.2.5.RELEASE" ,
"org.springframework" % "spring-test" % "3.2.5.RELEASE" % "test",
"org.scalatest" %% "scalatest" % "2.0" % "test"
)
<project>/<plugin>.sbt
project/Release.sbt:
addSbtPlugin( "com.earldouglas" % "xsbt-web-plugin" % "0.6.0" )
build.sbt:
import com.earldouglas.xsbtwebplugin.PluginKeys._
seq( webSettings:_* )
port in container.Configuration := 12345
Use the REPL to inspect your model:
inspect <key>
inspects the key metadatainspect tree <key>
inspects the dependency treeshow <key>
lists the valueThe REPL provides a specialized key syntax:
[project/][config:][task][::key]
> inspect tree compile // Simplified output
[info] my-project/compile:compile = Task[Analysis]
[info] +-my-project/compile:compile::compileInputs = Task[Compiler$Inputs]
[info] | +-*/*:maxErrors = 100
[info] | +-my-project/compile:dependencyClasspath = Task[Seq[File]]
[info] | +-my-project/compile:sources = Task[Seq[File]]
[info] | +-my-project/compile:scalacOptions = Task[Seq[String]]
[info] | +-my-project/compile:classDirectory = core/target/scala-2.10/classes
[info] | +-*/*:javacOptions = Task[Seq[String]]
[info] |
[info] +-my-project/compile:compile::streams = Task[...]
[info] +-*/*:streamsManager = Task[...]
...
> test
[info] ResultMatchersTest:
[info] RuleViolationMatcher
[info] - should correctly match a rule violation based on value
[info] - should fail to match a non-matching rule violation
[info] Run completed in 314 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[success] Total time: 1 s, completed Jan 20, 2014 3:52:58 PM
> ~test
[info] Compiling 11 Scala sources to /Users/tomer/dev/accord/core/target/scala-2.10/test-classes...
[error] /Users/tomer/dev/accord/core/src/test/scala/com/wix/accord/tests/dsl/OrderingOpsDslSpec.scala:52: not enough arguments for method between: (lowerBound: T, upperBound: T)(implicit evidence$1: Ordering[T])com.wix.accord.dsl.Between[T].
[error] one error found
[error] (accord-core/test:compile) Compilation failed
[error] Total time: 2 s, completed Jan 20, 2014 3:52:24 PM
1. Waiting for source changes... (press enter to interrupt)
arilou:dev tomer$ activator new
Enter an application name
> hello-scala
The new application will be created in /home/typesafe/Desktop/hello-scala
Enter a template name, or hit tab to see a list of possible templates
>
hello-akka hello-play hello-scala reactive-stocks
> hello-scala
OK, application "hello-scala" is being created using the
"hello-scala" template.
To run "hello-scala" from the command-line, run:
/home/typesafe/Desktop/hello-scala/activator run
... but is actually pretty well-documented
Dive into sources every now and then
... you'll learn a lot