How do I silence the Java 21 compiler from nagging about me using preview features? Here is what I have tried so far, UNSUCCESSFULLY:
-Xlint:all:tasks
.withType(JavaCompile)
.configureEach {
java {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
options.incremental = true
options.encoding = 'UTF-8'
options.compilerArgs += [
"--enable-preview",
"-Xlint:all",
"-Xlint:-preview"
]
}
}
@SuppressWarnings("preview") to all module-info.java definitions.Sampling of compiler warnings (files truncated with ... for brevity):
.../DataLoader.java:373: warning: [preview] string templates are a preview feature and may be removed in a future release.
logger.log(SEVERE, STR."Error after \{sheet}/\{rowCounter[0]}, \{t}");
^
.../DataLoader.java:373: warning: [preview] string templates are a preview feature and may be removed in a future release.
logger.log(SEVERE, STR."Error after \{sheet}/\{rowCounter[0]}, \{t}");
warning: [preview] class file .../Named.class) uses preview features of Java SE 21.
warning: [preview] class file for .../ExcelWorkbook$ExcelSheet.class uses preview features of Java SE 21.
warning: [preview] class file for ../Store.class) uses preview features of Java SE 21.
warning: [preview] class file for .../ExcelWorkbook$Field.class uses preview features of Java SE 21.
@andrewJames pointed to the solution in the comments:
options.compilerArgs += [
"--enable-preview",
"-Xlint:-preview"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With