chore: Improve setup-java actions #7531
Merged
+88
−201
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.
We are being incorrectly prescriptive in setting up Java in CI; the build currently requires JDK 21 (our default compiler version), 17 (javadocs and a few projects that set compilerVersion, runtimeVersion, or testRuntimeVersion to 17), and 11 (buildSrc explicitly sets to the 11 toolchain); we were currently getting "lucky" that all of these versions can be implicitly sourced from the hosted toolchain cache when not explicitly installed.
We may want to consider locking this down more in the future, and only telling gradle about the JDKs we've explicitly enabled; that is, not implicitly sourcing from the hosted tool cache.
Instead of sourcing the JDKs one-by-one, setup-java can source multiple at once: https://github.com/actions/setup-java/tree/v5?tab=readme-ov-file#install-multiple-jdks
This also removes the overly-strict requirement of "JDK 11 is currently required for CI builds". I suspect this was originally put in place as a safety measure when the gradle javaToolchain ecosystem was less mature and/or our setup of java requirements in gradle itself was less robust.