Skip to content

Compile build-logic with JDK 17 so the build runs on a JDK 17 daemon [CLF-286] - #1561

Merged
zach-klippenstein merged 1 commit into
mainfrom
zachklipp/build-logic-jdk17
Aug 18, 2026
Merged

Compile build-logic with JDK 17 so the build runs on a JDK 17 daemon [CLF-286]#1561
zach-klippenstein merged 1 commit into
mainfrom
zachklipp/build-logic-jdk17

Conversation

@zach-klippenstein

@zach-klippenstein zach-klippenstein commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Building workflow-kotlin on a stock JDK 17 environment (e.g. Square's sa-tools default of Azul 17) fails immediately:

Could not resolve project :build-logic.
> Dependency requires at least JVM runtime version 21. This build uses a Java 17 JVM.

Cause

jdk-toolchain = "21" was consumed in two structurally different places:

Site Effect Constrains the daemon?
KotlinCommonSettings.ktjvmToolchain(21) for library/sample modules Real Gradle toolchain; the daemon forks a JDK 21 compiler No
build-logic/build.gradle.kts — build-logic's own toolchain build-logic is on the buildscript classpath, so the daemon loads its classes directly Yes

Only the second forces JAVA_HOME to 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:

Version Purpose
jdk-target (11) Bytecode published to consumers — unchanged
jdk-toolchain (21) JDK the libraries compile with, matches android-register — unchanged
jdk-buildLogic (17) JDK build-logic compiles with — new

17 is the natural floor, since Gradle 9.3.1 and AGP 8.13 both already require JDK 17+.

CONTRIBUTING.md previously 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:

Check JDK 17 (Azul) JDK 21 (Temurin)
./gradlew test --continue ✅ 1582 tasks ✅ 1582 tasks
apiCheck artifactsCheck dependencyGuard

Published bytecode is unchanged — workflow-core classes are still major version 55 (Java 11), matching jdk-target. build-logic moves from 65 (Java 21) to 61 (Java 17).

Fixes CLF-286.

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
zach-klippenstein requested a review from a team as a code owner August 18, 2026 18:41
@zach-klippenstein zach-klippenstein changed the title Compile build-logic with JDK 17 so the build runs on a JDK 17 daemon [CL-286] Compile build-logic with JDK 17 so the build runs on a JDK 17 daemon [CLF-286] Aug 18, 2026
@steve-the-edwards

Copy link
Copy Markdown
Contributor

Fine with me but also fine keeping it JDK 21

@zach-klippenstein
zach-klippenstein merged commit af8ee1b into main Aug 18, 2026
75 checks passed
@zach-klippenstein
zach-klippenstein deleted the zachklipp/build-logic-jdk17 branch August 18, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants