From a6705d5fab69280e19ba3601da53cf476383f5fb Mon Sep 17 00:00:00 2001 From: BenchmarkingBuffalo <46448799+BenchmarkingBuffalo@users.noreply.github.com> Date: Tue, 12 Aug 2025 22:11:54 +0200 Subject: [PATCH] Fail fast with explicit error message for incompatible JDK version If the JDK version used to compile the software is not compatible with Java 24, the build fails fast with a hint what has gone wrong. This check happens on the 'projectsLoaded' hook. Fix gh-46625 Signed-off-by: BenchmarkingBuffalo <46448799+BenchmarkingBuffalo@users.noreply.github.com> --- settings.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/settings.gradle b/settings.gradle index 4f2cfa7992c1..5c7cfb0aaeaf 100644 --- a/settings.gradle +++ b/settings.gradle @@ -44,6 +44,11 @@ rootProject.name="spring-boot-build" enableFeaturePreview("STABLE_CONFIGURATION_CACHE") settings.gradle.projectsLoaded { + ensureCompatibleJavaVersion -> { + if (!JavaVersion.current().isCompatibleWith(JavaVersion.toVersion(24))) { + throw new GradleException("Java 24 or newer is needed to compile. Java version used is ${JavaVersion.current().toString()}.") + } + } develocity { buildScan { def toolchainVersion = settings.gradle.rootProject.findProperty('toolchainVersion')