How to force SBT to use Java 8?
Support in scalac for jvm-1.8 was added in 2.11.4.
Scala version (2.11.2) does not support -target:jvm-1.8
option.
$ scala -version
Scala code runner version 2.11.2 -- Copyright 2002-2013, LAMP/EPFL
$ scala -target
Usage: -target:<target>
where <target> choices are jvm-1.5, jvm-1.6, jvm-1.7 (default: jvm-1.6)
bad option: '-target'
Usage: scala <options> [<script|class|object|jar> <arguments>]
or scala -help
All options to scalac (see scalac -help) are also allowed.
You need the following on your build.sbt file.
javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")
initialize := {
val _ = initialize.value
val javaVersion = sys.props("java.specification.version")
if (javaVersion != "1.8")
sys.error("Java 1.8 is required for this project. Found " + javaVersion + " instead")
}