Compile build-logic with JDK 17 so the build runs on a JDK 17 daemon [CLF-286] - #1561
Merged
Merged
Conversation
build-logic is on the buildscript classpath, so the Gradle daemon loads its classes directly. Compiling it with the jdk-toolchain (21) meant the daemon itself had to be JDK 21, and building on a stock JDK 17 environment failed with: Could not resolve project :build-logic. > Dependency requires at least JVM runtime version 21. This build uses a Java 17 JVM. The 21 was inherited from the libraries' toolchain, which conflated two different things: the JDK the libraries compile with (a real Gradle toolchain, forked by the daemon) and the JDK the daemon must be able to load. Only the latter constrains JAVA_HOME. Split them with a new jdk-buildLogic version, set to 17 — the floor Gradle 9 and AGP 8 already require. The libraries still compile with the JDK 21 toolchain, so parity with android-register's compile JDK is preserved, and published bytecode is unchanged (jdk-target stays at 11). Also document the three JDK versions in CONTRIBUTING.md, which previously didn't mention any JDK requirement. Co-Authored-By: Claude <noreply@anthropic.com>
zach-klippenstein
enabled auto-merge
August 18, 2026 18:43
Contributor
|
Fine with me but also fine keeping it JDK 21 |
handstandsam
approved these changes
Aug 18, 2026
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.
Building workflow-kotlin on a stock JDK 17 environment (e.g. Square's
sa-toolsdefault of Azul 17) fails immediately:Cause
jdk-toolchain = "21"was consumed in two structurally different places:KotlinCommonSettings.kt—jvmToolchain(21)for library/sample modulesbuild-logic/build.gradle.kts— build-logic's own toolchainOnly the second forces
JAVA_HOMEto be 21. Nothing in build-logic needs Java 21 language features — it just inherited the libraries' value, conflating "JDK the libraries compile with" and "JDK the daemon must be able to load".This is why android-register builds fine on JDK 17 while workflow did not: android-register uses toolchains for compilation and keeps its daemon on 17.
Fix
Split the two concepts in the version catalog:
jdk-target(11)jdk-toolchain(21)jdk-buildLogic(17)17 is the natural floor, since Gradle 9.3.1 and AGP 8.13 both already require JDK 17+.
CONTRIBUTING.mdpreviously documented no JDK requirement at all, which is what made this bite silently; it now explains all three versions.Verification
Run locally on both JDKs:
./gradlew test --continueapiCheck artifactsCheck dependencyGuardPublished bytecode is unchanged —
workflow-coreclasses are still major version 55 (Java 11), matchingjdk-target.build-logicmoves from 65 (Java 21) to 61 (Java 17).Fixes CLF-286.