使用以下 Gradle 设置
sourceCompatibility = 1.12
targetCompatibility = 1.12
tasks.withType(JavaCompile) {
options.incremental = true
options.compilerArgs
the project will be compiled, the tests executed and the artifacts built on JDK 12.
However, in IntelliJ with the following common project structure
project
|_moduleA
|_main
|_test
|_moduleB
|_main
|_test
和语言级别设置为 12(预览版)- 切换表达式 只有项目和两个模块获得此语言级别。 主要 和 测试但是,模块会丢失设置,并且 IDEA 表示刷新 Gradle 项目时设置将丢失。那么 --启用预览应用设置以便源模块也保留设置?
最佳答案
我遇到了同样的问题,按照 gradle documentation 解决了:
tasks.withType(JavaCompile) {
options.compilerArgs += "--enable-preview"
}
tasks.withType(Test) {
jvmArgs += "--enable-preview"
}
tasks.withType(JavaExec) {
jvmArgs += "--enable-preview"
}
关于java - 如何为所有 Gradle 子模块启用 --enable-preview 以便它也保留在 IntelliJ IDEA 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55270540/