0

我该如何设置

idea {
    targetVersion = "13"
}

sourceCompatibility = 1.8

使用 gradle kotlin dsl 构建时来自 scala 插件https://docs.gradle.org/current/userguide/scala_plugin.html ?

4

1 回答 1

0

设置 IDEA 的目标版本是一个简单的复制粘贴:

build.gradle:

idea {
    targetVersion = "13"
}

build.gradle.kts:

idea {
    targetVersion = "13"
}

设置sourceCompatibility有点棘手:

build.gradle:

源兼容性 = 1.8

build.gradle.kts:

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

但是请注意,Gradle Scala 插件文档声明该sourceCompatibility选项基本上是无操作的。兼容的 Java 版本由 Scala 编译器确定,其中 2.11.x 以 Java 1.6 为目标,2.12.x 以 Java 1.8 为目标

于 2018-05-28T12:13:57.867 回答