Configuring Scala compile options in sbt 0.10.x versus previous versions

Upgrading a few existing sbt-based projects from 0.7.7 to 0.10.0 was relatively straightforward, but came with a few hurdles. One of these was the enabling of Scala compiler options such as -unchecked and -deprecation. Previously these could be declared by creating (or editing) a project definition file in project/build, something like the following:

class MyProject(info: ProjectInfo) extends DefaultProject(info) {
  override def compileOptions = super.compileOptions ++ Seq(Unchecked, Deprecation)
}

This method no longer works in 0.10.x, where instead compiler options are declared in the build.sbt file of the project root (along with many other properties formerly defined in the project definition) using the scalacoptions property:

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

This configuration parameter is of course well-documented on the sbt github page, but the change in names hung me up a bit. On the positive side, the new convention allows arbitrary compiler options more succinctly than previously, where non-built-in compiler options required use of the compileOptions(options: String*) method.

, , , , , , , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>