Scala SBT and build.sbt syntax and examples

Note: This page about SBT is very much a work in progress.

This page shows a sample Scala SBT build.sbt file, including the last line, which handles the SBT 're-run with -deprecation for details' warning message. (If you get the 're-run with -deprecation' message, that last line hands the "-deprecation" option over to the compiler, so you can see the deprecation problems.)

name := "Test 1"

version := "1.0"

scalaVersion := "2.9.1"

resolvers += "Typesafe Repository" at ""

libraryDependencies += "com.typesafe.akka" % "akka-actor" % "2.0.2"

// for debugging sbt problems
logLevel := Level.Debug

scalacOptions += "-deprecation"

The page I linked to also shows this approach:

scalacOptions ++= Seq("-unchecked", "-deprecation")

Another sample SBT configuration file (build.sbt)

Here's another sample build.sbt SBT configuration file I use on a Scalatra and MongoDB (and Casbah) Scala project:

organization := "com.devdaily"

name := "ScalatraTest1"

version := "0.1.0-SNAPSHOT"

scalaVersion := "2.9.1"

seq(webSettings :_*)

libraryDependencies ++= Seq(
  "org.scalatra" %% "scalatra" % "2.0.4",
  "org.scalatra" %% "scalatra-scalate" % "2.0.4",
  "org.scalatra" %% "scalatra-specs2" % "2.0.4" % "test",
  "ch.qos.logback" % "logback-classic" % "1.0.0" % "runtime",
  "org.eclipse.jetty" % "jetty-webapp" % "7.6.0.v20120127" % "container",
  "javax.servlet" % "servlet-api" % "2.5" % "provided",
  "com.mongodb.casbah" %% "casbah" % "2.1.5-1"

resolvers += "Sonatype OSS Snapshots" at ""

A script to build an SBT project directory structure

On a related note, here's a shell script that creates an SBT project directory structure.

scalacOptions options

tpolecat has put together a nice description of scalacOptions options (flags) at this URL. They’re also available at this page.