File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
src/main/java/org/springframework/boot/build Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,6 @@ plugins {
2222 id " org.jetbrains.dokka" version " 2.1.0"
2323}
2424
25- if (! JavaVersion . current(). isCompatibleWith(JavaVersion . VERSION_24 )) {
26- throw new GradleException (" This build requires Java 24 or newer to run, but you are currently using Java ${ JavaVersion.current()} " )
27- }
28-
2925repositories {
3026 mavenCentral()
3127 spring. mavenRepositoriesFor(" ${ springFrameworkVersion} " )
Original file line number Diff line number Diff line change 3232import io .spring .javaformat .gradle .SpringJavaFormatPlugin ;
3333import io .spring .javaformat .gradle .tasks .CheckFormat ;
3434import io .spring .javaformat .gradle .tasks .Format ;
35+ import org .gradle .api .GradleException ;
3536import org .gradle .api .JavaVersion ;
3637import org .gradle .api .Project ;
3738import org .gradle .api .Task ;
@@ -143,6 +144,7 @@ void apply(Project project) {
143144 configureProhibitedDependencyChecks (project );
144145 configureFactoriesFilesChecks (project );
145146 configureNullability (project );
147+ configureJavaVersionCompatibility (project );
146148 });
147149 }
148150
@@ -352,4 +354,14 @@ private void configureNullability(Project project) {
352354 }
353355 }
354356
357+ private void configureJavaVersionCompatibility (Project project ) {
358+ project .getTasks ().withType (JavaCompile .class ).configureEach ((javaCompile ) -> javaCompile .doFirst ((task ) -> {
359+ JavaVersion version = JavaVersion .current ();
360+ if (!version .isCompatibleWith (JavaVersion .VERSION_24 )) {
361+ throw new GradleException ("This build requires Java %s or newer, but you are using Java %s"
362+ .formatted (JavaVersion .VERSION_24 , version ));
363+ }
364+ }));
365+ }
366+
355367}
You can’t perform that action at this time.
0 commit comments