Skip to content

Commit d213d41

Browse files
committed
Ignore warnings regarding Java 8 compilation warnings
1 parent df850d4 commit d213d41

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

buildSrc/src/main/kotlin/ai.java-conventions.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ tasks.withType<JavaCompile>().configureEach {
3232
with(options) {
3333
release.set(8)
3434
compilerArgs.add("-Werror")
35+
// We need to support compiling to Java 8 even when using JDK 21 to build.
36+
// Suppress obsolete source/target warning added in JDK 21 while retaining -Werror for everything else.
37+
// This only disables the 'options' lint category (e.g., the obsolete source/target messages).
38+
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_21)) {
39+
compilerArgs.add("-Xlint:-options")
40+
}
3541
}
3642
}
3743

buildSrc/src/main/kotlin/ai.smoke-test.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ tasks.withType<JavaCompile>().configureEach {
3838
with(options) {
3939
release.set(8)
4040
compilerArgs.add("-Werror")
41+
// We need to support compiling to Java 8 even when using JDK 21 to build.
42+
// Suppress obsolete source/target warning added in JDK 21 while retaining -Werror for everything else.
43+
// This only disables the 'options' lint category (e.g., the obsolete source/target messages).
44+
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_21)) {
45+
compilerArgs.add("-Xlint:-options")
46+
}
4147
}
4248
}
4349

smoke-tests/apps/DiagnosticExtension/MockExtension/build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ tasks.withType<JavaCompile>().configureEach {
1818
with(options) {
1919
release.set(8)
2020
compilerArgs.add("-Werror")
21+
// We need to support compiling to Java 8 even when using JDK 21 to build.
22+
// Suppress obsolete source/target warning added in JDK 21 while retaining -Werror for everything else.
23+
// This only disables the 'options' lint category (e.g., the obsolete source/target messages).
24+
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_21)) {
25+
compilerArgs.add("-Xlint:-options")
26+
}
2127
}
2228
}
2329

0 commit comments

Comments
 (0)