Compile options for Scala in Gradle

The Scala plugin for Gradle is well documented, but the documentation lacks code snippets with example. So I decide to leave this code snippet here. It set compilation options for both Java and Scala compilers doing joint compilation. The particular option enabled here turns on Scala and Java warnings.

tasks.withType(ScalaCompile) {
    // Use incremental compilation
    scalaCompileOptions.useAnt = false
    // Enable Scala warnings output
    scalaCompileOptions.additionalParameters = ["-feature"]
compileScala {
  // Enable Java warnings output
  options.compilerArgs << "-Xlint:unchecked"

The snippet shows two different ways to specify compiler options. First would affect every scala compilation task, the second would only apply to the main code compilations, leaving other tasks (for example :compileTestScala) unchanged.