Skip to content

Commit

Permalink
Update Gradle config to always compile Java code using JDK 17 (#971)
Browse files Browse the repository at this point in the history
Before this change, if Gradle itself was running on JDK 21+, compilation
would fail.
  • Loading branch information
msridhar committed Jun 5, 2024
1 parent f1a14d4 commit 38edf57
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ subprojects { project ->
}
project.tasks.withType(JavaCompile) {
dependsOn(installGitHooks)
// Always compile using JDK 17, independent of the JDK version used to run Gradle.
// We can't compile on JDK 21 since some internal javac APIs changed between 17
// and 21, and for now NullAway compiles against the JDK 17 APIs and uses reflection
// on JDK 21+. This configuration means compilation will succeed even if Gradle
// is running on JDK 21+.
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
}
options.compilerArgs += [
"-Xlint:deprecation",
"-Xlint:rawtypes",
Expand Down

0 comments on commit 38edf57

Please sign in to comment.