'jvm-1.8' is not a valid choice for '-target'

I got the same error message using IntelliJ 2017.2.5 w/ JRE 1.8.0, scala 2.10.5 and gradle 3.3. I solved my problem by checking the "Delegate IDE build/run actions to gradle" checkbox in IntelliJ's IDE located at

Settings>Build,Execution,Deployment>Build Tools>Gradle>Runner

Details can be found here: https://docs.gradle.org/4.2.1/userguide/scala_plugin.html#ideaTargetVersion and https://www.jetbrains.com/help/idea/gradle.html

Of note, I was able to build my gradle project outside of IntelliJ (i.e. cmd line) and only received this error on attempting to build using the IntelliJ IDE.


Gradle by default use the ant task to build Scala code, and https://issues.scala-lang.org/browse/SI-8966 shows that jvm 1.8 was not added as a supported target until Scala 2.11.5.

You can try using the Zinc based compiler with by adding the following the gradle build file.

    tasks.withType(ScalaCompile) {
      scalaCompileOptions.useAnt = false
    }

You may also need to add the zinc compiler to your dependency list.


In Intellij IDEA (15 CE) add this scalac compiler option:

Build, Execution, Deployment -> Compiler -> Scala Compiler -> Default

Additional compiler options: -target:jvm-1.7 (was empty).

There were also profiles Gradle 1, ... with -target:jvm-1.8, so I changed them also to -target:jvm-1.7.

I'm using Scala 2.10, JVM 1.8, source compatibility 1.7. It helped in my case.


I was searching for a solution for this for ages, finally found it - sharing for anyone else reading this.

Taken from: https://devnet.jetbrains.com/message/5523902

subprojects {
    tasks.withType(ScalaCompile) {
        sourceCompatibility = "1.7"
        targetCompatibility = "1.7"
    }
}