Skip to content

Commit 9000856

Browse files
committed
Raise the minimum supported version of Java to 17
Closes spring-projectsgh-28101
1 parent 99f33ed commit 9000856

File tree

15 files changed

+62
-262
lines changed

15 files changed

+62
-262
lines changed

buildSrc/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ repositories {
1010
maven { url "https://repo.spring.io/release" }
1111
}
1212

13-
sourceCompatibility = 1.8
14-
targetCompatibility = 1.8
13+
sourceCompatibility = 17
14+
targetCompatibility = 17
1515

1616
dependencies {
1717
checkstyle "io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}"
@@ -22,8 +22,8 @@ dependencies {
2222
implementation("org.gradle:test-retry-gradle-plugin:1.1.9")
2323
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0")
2424
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.5.0")
25-
implementation("org.springframework:spring-core:5.2.2.RELEASE")
26-
implementation("org.springframework:spring-web:5.2.2.RELEASE")
25+
implementation("org.springframework:spring-core:5.3.10")
26+
implementation("org.springframework:spring-web:5.3.10")
2727
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}")
2828
testImplementation("org.assertj:assertj-core:3.11.1")
2929
testImplementation("org.apache.logging.log4j:log4j-core:2.12.1")

buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.gradle.api.tasks.compile.JavaCompile;
4646
import org.gradle.api.tasks.javadoc.Javadoc;
4747
import org.gradle.api.tasks.testing.Test;
48+
import org.gradle.external.javadoc.CoreJavadocOptions;
4849
import org.gradle.testretry.TestRetryPlugin;
4950
import org.gradle.testretry.TestRetryTaskExtension;
5051

@@ -59,7 +60,7 @@
5960
* plugin is applied:
6061
*
6162
* <ul>
62-
* <li>The project is configured with source and target compatibility of 1.8
63+
* <li>The project is configured with source and target compatibility of 17
6364
* <li>{@link SpringJavaFormatPlugin Spring Java Format}, {@link CheckstylePlugin
6465
* Checkstyle}, {@link TestFailuresPlugin Test Failures}, and {@link TestRetryPlugin Test
6566
* Retry} plugins are applied
@@ -74,9 +75,9 @@
7475
* {@link JavaPlugin} applied
7576
* <li>{@link JavaCompile}, {@link Javadoc}, and {@link Format} tasks are configured to
7677
* use UTF-8 encoding
77-
* <li>{@link JavaCompile} tasks are configured to use {@code -parameters}.
78-
* <li>When building with Java 8, {@link JavaCompile} tasks are also configured to:
78+
* <li>{@link JavaCompile} tasks are configured to:
7979
* <ul>
80+
* <li>Use {@code -parameters}.
8081
* <li>Treat warnings as errors
8182
* <li>Enable {@code unchecked}, {@code deprecation}, {@code rawtypes}, and {@code varags}
8283
* warnings
@@ -102,7 +103,7 @@
102103
*/
103104
class JavaConventions {
104105

105-
private static final String SOURCE_AND_TARGET_COMPATIBILITY = "1.8";
106+
private static final String SOURCE_AND_TARGET_COMPATIBILITY = "17";
106107

107108
void apply(Project project) {
108109
project.getPlugins().withType(JavaBasePlugin.class, (java) -> {
@@ -178,7 +179,12 @@ private boolean isCi() {
178179
}
179180

180181
private void configureJavadocConventions(Project project) {
181-
project.getTasks().withType(Javadoc.class, (javadoc) -> javadoc.getOptions().source("1.8").encoding("UTF-8"));
182+
project.getTasks().withType(Javadoc.class, (javadoc) -> {
183+
CoreJavadocOptions options = (CoreJavadocOptions) javadoc.getOptions();
184+
options.source("17");
185+
options.encoding("UTF-8");
186+
options.addStringOption("Xdoclint:none", "-quiet");
187+
});
182188
}
183189

184190
private void configureJavaConventions(Project project) {
@@ -196,17 +202,11 @@ private void configureJavaConventions(Project project) {
196202
compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
197203
compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
198204
}
199-
else if (buildingWithJava8(project)) {
200-
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
201-
"-Xlint:varargs"));
202-
}
205+
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
206+
"-Xlint:varargs"));
203207
});
204208
}
205209

206-
private boolean buildingWithJava8(Project project) {
207-
return !project.hasProperty("toolchainVersion") && JavaVersion.current() == JavaVersion.VERSION_1_8;
208-
}
209-
210210
private void configureSpringJavaFormat(Project project) {
211211
project.getPlugins().apply(SpringJavaFormatPlugin.class);
212212
project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8"));

buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/MavenPluginPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private MavenExec addGenerateHelpMojoTask(Project project, Jar jarTask) {
144144
private MavenExec createGenerateHelpMojoTask(Project project, File helpMojoDir) {
145145
MavenExec task = project.getTasks().create("generateHelpMojo", MavenExec.class);
146146
task.setProjectDir(helpMojoDir);
147-
task.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.0:helpmojo");
147+
task.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.1:helpmojo");
148148
task.getOutputs().dir(new File(helpMojoDir, "target/generated-sources/plugin"));
149149
return task;
150150
}
@@ -211,7 +211,7 @@ private Copy createCopyPluginDescriptorInputs(Project project, File destination,
211211

212212
private MavenExec createGeneratePluginDescriptorTask(Project project, File mavenDir) {
213213
MavenExec generatePluginDescriptor = project.getTasks().create("generatePluginDescriptor", MavenExec.class);
214-
generatePluginDescriptor.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.0:descriptor");
214+
generatePluginDescriptor.args("org.apache.maven.plugins:maven-plugin-plugin:3.6.1:descriptor");
215215
generatePluginDescriptor.getOutputs().dir(new File(mavenDir, "target/classes/META-INF/maven"));
216216
generatePluginDescriptor.getInputs().dir(new File(mavenDir, "target/classes/org"))
217217
.withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("plugin classes");

buildSrc/src/test/java/org/springframework/boot/build/ConventionsPluginTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void jarIncludesLegalFiles() throws IOException {
7373
out.println(" id 'org.springframework.boot.conventions'");
7474
out.println("}");
7575
out.println("version = '1.2.3'");
76-
out.println("sourceCompatibility = '1.8'");
76+
out.println("sourceCompatibility = '17'");
7777
out.println("description 'Test project for manifest customization'");
7878
out.println("jar.archiveFileName = 'test.jar'");
7979
}
@@ -90,7 +90,7 @@ void jarIncludesLegalFiles() throws IOException {
9090
.isEqualTo(this.projectDir.getName().replace("-", "."));
9191
assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3");
9292
assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring");
93-
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("1.8");
93+
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("17");
9494
}
9595
}
9696

@@ -103,7 +103,7 @@ void sourceJarIsBuilt() throws IOException {
103103
out.println(" id 'org.springframework.boot.conventions'");
104104
out.println("}");
105105
out.println("version = '1.2.3'");
106-
out.println("sourceCompatibility = '1.8'");
106+
out.println("sourceCompatibility = '17'");
107107
out.println("description 'Test'");
108108
out.println("repositories {");
109109
out.println(" mavenCentral()");
@@ -125,7 +125,7 @@ void sourceJarIsBuilt() throws IOException {
125125
.isEqualTo(this.projectDir.getName().replace("-", "."));
126126
assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3");
127127
assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring");
128-
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("1.8");
128+
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("17");
129129
}
130130
}
131131

@@ -138,7 +138,7 @@ void javadocJarIsBuilt() throws IOException {
138138
out.println(" id 'org.springframework.boot.conventions'");
139139
out.println("}");
140140
out.println("version = '1.2.3'");
141-
out.println("sourceCompatibility = '1.8'");
141+
out.println("sourceCompatibility = '17'");
142142
out.println("description 'Test'");
143143
out.println("repositories {");
144144
out.println(" mavenCentral()");
@@ -160,7 +160,7 @@ void javadocJarIsBuilt() throws IOException {
160160
.isEqualTo(this.projectDir.getName().replace("-", "."));
161161
assertThat(mainAttributes.getValue("Implementation-Version")).isEqualTo("1.2.3");
162162
assertThat(mainAttributes.getValue("Built-By")).isEqualTo("Spring");
163-
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("1.8");
163+
assertThat(mainAttributes.getValue("Build-Jdk-Spec")).isEqualTo("17");
164164
}
165165
}
166166

ci/images/ci-image-jdk11/Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

ci/images/ci-image-jdk17/Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

ci/images/ci-image/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM ubuntu:focal-20211006
33
ADD setup.sh /setup.sh
44
ADD get-jdk-url.sh /get-jdk-url.sh
55
ADD get-docker-url.sh /get-docker-url.sh
6-
RUN ./setup.sh java8
6+
RUN ./setup.sh java17
77

88
ENV JAVA_HOME /opt/openjdk
99
ENV PATH $JAVA_HOME/bin:$PATH

ci/images/get-jdk-url.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
set -e
33

44
case "$1" in
5-
java8)
6-
echo "https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u312-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u312b07.tar.gz"
7-
;;
8-
java11)
9-
echo "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.13%2B8/OpenJDK11U-jdk_x64_linux_hotspot_11.0.13_8.tar.gz"
10-
;;
115
java17)
126
echo "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz"
137
;;

0 commit comments

Comments
 (0)