Raise the minimum supported version of Gradle to 8.14 and support 9.x

Closes gh-43573
Closes gh-43574
This commit is contained in:
Andy Wilkinson
2025-08-19 11:11:06 +01:00
parent 243a1352f4
commit f4fd2126bb
8 changed files with 67 additions and 18 deletions
@@ -3,6 +3,6 @@
The Spring Boot Gradle Plugin provides Spring Boot support in https://gradle.org[Gradle].
It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by `spring-boot-dependencies`.
Spring Boot's Gradle plugin requires Gradle 7.x (7.6.4 or later) or 8.x (8.4 or later) and can be used with Gradle's {url-gradle-docs}/configuration_cache.html[configuration cache].
Spring Boot's Gradle plugin requires Gradle 8.x (8.14 or later) or 9.x and can be used with Gradle's {url-gradle-docs}/configuration_cache.html[configuration cache].
In addition to this user guide, xref:api/java/index.html[API documentation] is also available.
@@ -3,6 +3,6 @@
The Spring Boot Gradle Plugin provides Spring Boot support in https://gradle.org[Gradle].
It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by `spring-boot-dependencies`.
Spring Boot's Gradle plugin requires Gradle 7.x (7.6.4 or later) or 8.x (8.4 or later) and can be used with Gradle's {url-gradle-docs}/configuration_cache.html[configuration cache].
Spring Boot's Gradle plugin requires Gradle 8.x (8.14 or later) or 9.x and can be used with Gradle's {url-gradle-docs}/configuration_cache.html[configuration cache].
In addition to this user guide, xref:api/java/index.html[API documentation] is also available.
@@ -20,9 +20,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.util.GradleVersion;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.gradle.dsl.SpringBootExtension;
@@ -115,11 +117,20 @@ public class SpringBootPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
verifyGradleVersion();
createExtension(project);
Configuration bootArchives = createBootArchivesConfiguration(project);
registerPluginActions(project, bootArchives);
}
private void verifyGradleVersion() {
GradleVersion currentVersion = GradleVersion.current();
if (currentVersion.compareTo(GradleVersion.version("8.14")) < 0) {
throw new GradleException("Spring Boot plugin requires Gradle 8.x (8.14 or later) or 9.x. "
+ "The current version is " + currentVersion);
}
}
private void createExtension(Project project) {
project.getExtensions().create("springBoot", SpringBootExtension.class, project);
}
@@ -0,0 +1,50 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.gradle.plugin;
import org.gradle.testkit.runner.BuildResult;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.gradle.testkit.PluginClasspathGradleBuild;
import org.springframework.boot.testsupport.BuildOutput;
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
import org.springframework.boot.testsupport.gradle.testkit.GradleBuildExtension;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration tests for {@link SpringBootPlugin}.
*
* @author Andy Wilkinson
*/
@ExtendWith(GradleBuildExtension.class)
class SpringBootPluginIntegrationTests {
final GradleBuild gradleBuild = new PluginClasspathGradleBuild(new BuildOutput(getClass()));
@Test
@DisabledForJreRange(min = JRE.JAVA_24)
void failFastWithVersionOfGradle8LowerThanRequired() {
BuildResult result = this.gradleBuild.gradleVersion("8.13").buildAndFail();
assertThat(result.getOutput()).contains(
"Spring Boot plugin requires Gradle 8.x (8.14 or later) or 9.x. The current version is Gradle 8.13");
}
}
@@ -15,5 +15,5 @@
*/
plugins {
id 'org.springframework.boot' version '{version}'
id 'org.springframework.boot'
}