Skip to content

Commit c8e9242

Browse files
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 <[email protected]>
1 parent 0bc97ae commit c8e9242

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

settings.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ rootProject.name="spring-boot-build"
4444
enableFeaturePreview("STABLE_CONFIGURATION_CACHE")
4545

4646
settings.gradle.projectsLoaded {
47+
ensureCompatibleJavaVersion -> {
48+
if (!JavaVersion.current().isCompatibleWith(JavaVersion.toVersion(24))) {
49+
throw new GradleException("Java 24 or newer is needed to compile. Java version used is ${JavaVersion.current().toString()}.")
50+
}
51+
}
4752
develocity {
4853
buildScan {
4954
def toolchainVersion = settings.gradle.rootProject.findProperty('toolchainVersion')

0 commit comments

Comments
 (0)