提问人:pixel 提问时间:11/13/2023 最后编辑:pixel 更新时间:11/13/2023 访问量:40
使用 gradle 编译 Java 任务时摆脱预览警告?[复制]
Get rid of preview warning when with gradle compileJava task? [duplicate]
问:
我按如下方式配置了我的 Gradle 构建:
tasks {
val preview = "--enable-preview"
withType<JavaCompile> {
options.compilerArgs.add(preview)
options.compilerArgs.add("-Xlint:preview")
}
withType<Test> {
useJUnitPlatform()
jvmArgs = jvmArgs!! + preview
}
withType<JavaExec> {
jvmArgs = jvmArgs!! + preview
}
}
但是,当我编译时,我得到:
> Task :compileJava
warning: [preview] string templates are a preview feature and may be removed in a future release.
答:
1赞
Stephen C
11/13/2023
#1
根据手册,启用预览功能的使用情况检查。-Xlint:preview
尝试改用;即-Xlint:-preview
options.compilerArgs.add("-Xlint:-preview")
评论