Skip to content

Commit f4fd212

Browse files
committed
Raise the minimum supported version of Gradle to 8.14 and support 9.x
Closes gh-43573 Closes gh-43574
1 parent 243a135 commit f4fd212

File tree

8 files changed

+67
-18
lines changed

8 files changed

+67
-18
lines changed

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
The Spring Boot Gradle Plugin provides Spring Boot support in https://gradle.org[Gradle].
55
It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by `spring-boot-dependencies`.
6-
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].
6+
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].
77

88
In addition to this user guide, xref:api/java/index.html[API documentation] is also available.

build-plugin/spring-boot-gradle-plugin/src/docs/antora/modules/gradle-plugin/pages/introduction.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
The Spring Boot Gradle Plugin provides Spring Boot support in https://gradle.org[Gradle].
55
It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by `spring-boot-dependencies`.
6-
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].
6+
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].
77

88
In addition to this user guide, xref:api/java/index.html[API documentation] is also available.

build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
import java.util.List;
2121
import java.util.function.Consumer;
2222

23+
import org.gradle.api.GradleException;
2324
import org.gradle.api.Plugin;
2425
import org.gradle.api.Project;
2526
import org.gradle.api.artifacts.Configuration;
27+
import org.gradle.util.GradleVersion;
2628
import org.jspecify.annotations.Nullable;
2729

2830
import org.springframework.boot.gradle.dsl.SpringBootExtension;
@@ -115,11 +117,20 @@ public class SpringBootPlugin implements Plugin<Project> {
115117

116118
@Override
117119
public void apply(Project project) {
120+
verifyGradleVersion();
118121
createExtension(project);
119122
Configuration bootArchives = createBootArchivesConfiguration(project);
120123
registerPluginActions(project, bootArchives);
121124
}
122125

126+
private void verifyGradleVersion() {
127+
GradleVersion currentVersion = GradleVersion.current();
128+
if (currentVersion.compareTo(GradleVersion.version("8.14")) < 0) {
129+
throw new GradleException("Spring Boot plugin requires Gradle 8.x (8.14 or later) or 9.x. "
130+
+ "The current version is " + currentVersion);
131+
}
132+
}
133+
123134
private void createExtension(Project project) {
124135
project.getExtensions().create("springBoot", SpringBootExtension.class, project);
125136
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2012-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.gradle.plugin;
18+
19+
import org.gradle.testkit.runner.BuildResult;
20+
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.condition.DisabledForJreRange;
22+
import org.junit.jupiter.api.condition.JRE;
23+
import org.junit.jupiter.api.extension.ExtendWith;
24+
25+
import org.springframework.boot.gradle.testkit.PluginClasspathGradleBuild;
26+
import org.springframework.boot.testsupport.BuildOutput;
27+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
28+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuildExtension;
29+
30+
import static org.assertj.core.api.Assertions.assertThat;
31+
32+
/**
33+
* Integration tests for {@link SpringBootPlugin}.
34+
*
35+
* @author Andy Wilkinson
36+
*/
37+
@ExtendWith(GradleBuildExtension.class)
38+
class SpringBootPluginIntegrationTests {
39+
40+
final GradleBuild gradleBuild = new PluginClasspathGradleBuild(new BuildOutput(getClass()));
41+
42+
@Test
43+
@DisabledForJreRange(min = JRE.JAVA_24)
44+
void failFastWithVersionOfGradle8LowerThanRequired() {
45+
BuildResult result = this.gradleBuild.gradleVersion("8.13").buildAndFail();
46+
assertThat(result.getOutput()).contains(
47+
"Spring Boot plugin requires Gradle 8.x (8.14 or later) or 9.x. The current version is Gradle 8.13");
48+
}
49+
50+
}

build-plugin/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/plugin/SpringBootPluginIntegrationTests.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
*/
1616

1717
plugins {
18-
id 'org.springframework.boot' version '{version}'
18+
id 'org.springframework.boot'
1919
}

documentation/spring-boot-docs/src/docs/antora/modules/ROOT/pages/installing.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ More details on getting started with Spring Boot and Maven can be found in the x
4949
[[getting-started.installing.java.gradle]]
5050
=== Gradle Installation
5151

52-
Spring Boot is compatible with Gradle 7.x (7.6.4 or later) or 8.x (8.4 or later).
52+
Spring Boot is compatible with Gradle 8.x (8.14 or later) or 9.x.
5353
If you do not already have Gradle installed, you can follow the instructions at https://gradle.org.
5454

5555
Spring Boot dependencies can be declared by using the `org.springframework.boot` `group`.

documentation/spring-boot-docs/src/docs/antora/modules/ROOT/pages/system-requirements.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Explicit build support is provided for the following build tools:
1313
| 3.6.3 or later
1414

1515
| Gradle
16-
| Gradle 7.x (7.6.4 or later) or 8.x (8.4 or later)
16+
| Gradle 8.x (8.14 or later) and 9.x
1717
|===
1818

1919

test-support/spring-boot-gradle-test-support/src/main/java/org/springframework/boot/testsupport/gradle/testkit/GradleVersions.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,7 @@ private GradleVersions() {
3333
}
3434

3535
public static List<String> allCompatible() {
36-
if (isJavaVersion(JavaVersion.VERSION_24)) {
37-
return Arrays.asList(GradleVersion.current().getVersion(), "9.0.0", "9.1.0-rc-1");
38-
}
39-
if (isJavaVersion(JavaVersion.VERSION_23)) {
40-
return Arrays.asList(GradleVersion.current().getVersion(), "9.0.0", "9.1.0-rc-1");
41-
}
42-
if (isJavaVersion(JavaVersion.VERSION_22)) {
43-
return Arrays.asList("8.8", GradleVersion.current().getVersion(), "9.0.0", "9.1.0-rc-1");
44-
}
45-
if (isJavaVersion(JavaVersion.VERSION_21)) {
46-
return Arrays.asList("8.5", GradleVersion.current().getVersion(), "9.0.0", "9.1.0-rc-1");
47-
}
48-
return Arrays.asList("7.6.6", "8.4", GradleVersion.current().getVersion(), "9.0.0", "9.1.0-rc-1");
36+
return Arrays.asList(GradleVersion.current().getVersion(), "9.0.0", "9.1.0-rc-1");
4937
}
5038

5139
public static String minimumCompatible() {

0 commit comments

Comments
 (0)