带有以下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(预览) - Switch表达式仅项目和两个模块获得此语言级别。 MAIN 和 test 模块丢失了设置,想法说,当Gradle项目将刷新时,设置将丢失。那么,如何应用 - 启用Preview 设置,以便源模块保持设置?
我也有相同的问题,在gradle文档之后解决了:
tasks.withType(JavaCompile) {
options.compilerArgs += "--enable-preview"
}
tasks.withType(Test) {
jvmArgs += "--enable-preview"
}
tasks.withType(JavaExec) {
jvmArgs += "--enable-preview"
}