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?
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")
}
This is due to a bug in IntelliJ (or IntelliJ's Scala plugin):
https://youtrack.jetbrains.com/issue/SCL-18813
I have posted there a workaround, which was inspired by IvanoBulo's answer above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.