Java 如何为所有Gradle子模块启用--enable preview,使其也保留在IntelliJ IDEA中?

Java 如何为所有Gradle子模块启用--enable preview,使其也保留在IntelliJ IDEA中?,java,gradle,intellij-idea,preview,Java,Gradle,Intellij Idea,Preview,使用以下渐变设置 sourceCompatibility = 1.12 targetCompatibility = 1.12 tasks.withType(JavaCompile) { options.incremental = true options.compilerArgs sourceCompatibility=1.12 targetCompatibility=1.12 tasks.withType(JavaCompile){ options.incremental

使用以下渐变设置


sourceCompatibility = 1.12
targetCompatibility = 1.12

tasks.withType(JavaCompile) {
    options.incremental = true
    options.compilerArgs

sourceCompatibility=1.12
targetCompatibility=1.12
tasks.withType(JavaCompile){
options.incremental=true
options.compilerArgs
该项目将被编译,执行测试,并在JDK12上构建工件。
但是,在IntelliJ中,使用以下通用项目结构
project
|_moduleA
  |_main
  |_test
|_moduleB
  |_main
  |_test
项目 |_模 |_主要 |_试验 |_模B |_主要 |_试验
语言级别设置为12(预览)-切换表达式仅项目和两个模块获得此语言级别。maintest模块将丢失设置,IDEA表示,当Gradle项目刷新时,设置将丢失。
那么如何应用--enable preview设置,以便源模块也保留该设置呢?

我遇到了同样的问题,解决方法如下:


具有语言级别
12(无新语言功能)
12(预览)
尚不受Gradle支持。如果该版本在2018.3版中不适用,请尝试该版本。maven编译器插件也存在同样的问题,我包括--启用作为编译器args的预览,但重新导入时,它会将intellij中的模块语言级别从12(预览)更改为12(无新的语言功能),使我疯狂地不得不将其切换回去,直到我取消选中自动导入Maven项目。
tasks.withType(JavaCompile) {
    options.compilerArgs += "--enable-preview"
}
tasks.withType(Test) {
    jvmArgs += "--enable-preview"
}
tasks.withType(JavaExec) {
    jvmArgs += "--enable-preview"
}