Pin the Java toolchain to JDK 21 using java { toolchain {…} }#4366
Open
RobertBrunel wants to merge 1 commit into
Open
Pin the Java toolchain to JDK 21 using java { toolchain {…} }#4366RobertBrunel wants to merge 1 commit into
java { toolchain {…} }#4366RobertBrunel wants to merge 1 commit into
Conversation
* Use `toolchain { languageVersion = … }` to reliably pin the Java toolchain to JDK 21. This decouples the build from whatever JDK the developer happens to have on `PATH`.
* Disable auto-provisioning of JDKs. Gradle will pick a matching JDK from its detected local JDK installations.
* Drop the manual `JavaVersion.current().isCompatibleWith(VERSION_17)` guard. It is no longer necessary because the toolchain already ensures an appropriate JDK will be used.
* Apply `options.release = 17` to **every** `JavaCompile` task. Previously it was only `compileJava`, so tests were actually targeting Java 21.
* Remove a JDK 19 dependency from `PendingWritesQueueConcurrencyTest` to make it compile under `--release 17`.
Apart from pinning the JDK cleanly, toolchains also interact better with the Build Cache. Gradle folds the toolchain JDK identity into the build cache key, so cached compile outputs are tied to the JDK that produced them rather than just to `javac` arguments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
toolchain { languageVersion = … }to reliably pin the Java toolchain to JDK 21. This decouples the build from whatever JDK the developer happens to have onPATH.JavaVersion.current().isCompatibleWith(VERSION_17)guard. It is no longer necessary because the toolchain already ensures an appropriate JDK will be used.options.release = 17to everyJavaCompiletask. Previously it was onlycompileJava, so tests were actually targeting Java 21.PendingWritesQueueConcurrencyTestto make it compile under--release 17.Apart from pinning the JDK cleanly, toolchains also interact better with the Build Cache. Gradle folds the toolchain JDK identity into the build cache key, so cached compile outputs are tied to the JDK that produced them rather than just to
javacarguments.