简体   繁体   English

Gradle Kotlin DSL Scala和想法

[英]gradle kotlin DSL scala & idea

How can I set 我该如何设定

idea {
    targetVersion = "13"
}

and

sourceCompatibility = 1.8

from the scala plugin https://docs.gradle.org/current/userguide/scala_plugin.html when building using the gradle kotlin dsl? 从scala插件https://docs.gradle.org/current/userguide/scala_plugin.html使用gradle kotlin dsl进行构建时?

Setting the target version of IDEA is a simple copy-paste: 设置IDEA的目标版本是一个简单的复制粘贴:

build.gradle:

 idea { targetVersion = "13" } 

build.gradle.kts:

idea {
    targetVersion = "13"
}

Setting the sourceCompatibility is a bit trickier: 设置sourceCompatibility有点棘手:

build.gradle:

sourceCompatibility = 1.8 sourceCompatibility = 1.8

build.gradle.kts:

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

Do note however, that the Gradle Scala plugin docs state that the sourceCompatibility option is basically a no-op. 但是请注意, Gradle Scala插件文档指出sourceCompatibility选项基本上是无操作的。 The compatible Java version is determined by the Scala compiler, where 2.11.x targets Java 1.6, and 2.12.x targets Java 1.8 兼容的Java版本由Scala编译器确定,其中2.11.x针对Java 1.6,而2.12.x针对Java 1.8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM