Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala build error on Java 11 using intellijidea

When I build my project from IntellijIdea I get the following errors

Error:scalac: 'jvm-11' is not a valid choice for '-target'
Error:scalac: bad option: '-target:jvm-11'

I am using gradle to build my project. My project is using java 11 and scala 2.12.8.

Can someone help me resolve this error?

like image 545
Dilip Baluguri Avatar asked Nov 07 '22 20:11

Dilip Baluguri


1 Answers

Scala 2.12 doesn't support JVM 11 as a target. You need to add this to your gradle build file:

tasks.withType<ScalaCompile> {
    targetCompatibility = "1.8"
}

As for Scala 2.13, the fix for this issue is:

tasks.withType<ScalaCompile>() {
    targetCompatibility = ""
    scalaCompileOptions.additionalParameters = listOf("-target:11")
}
like image 122
IvanoBulo Avatar answered Nov 15 '22 07:11

IvanoBulo