Skip to content

Commit 2f298bc

Browse files
committed
Compile with Java 23 and -release 17
1 parent e05e16d commit 2f298bc

File tree

11 files changed

+34
-36
lines changed

11 files changed

+34
-36
lines changed

.github/actions/build/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ inputs:
3535
java-version:
3636
description: 'Java version to compile and test with'
3737
required: false
38-
default: '17'
38+
default: '23'
3939
publish:
4040
description: 'Whether to publish artifacts ready for deployment to Artifactory'
4141
required: false

.github/actions/prepare-gradle-build/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ inputs:
2323
java-version:
2424
description: 'Java version to use for the build'
2525
required: false
26-
default: '17'
26+
default: '23'
2727
runs:
2828
using: composite
2929
steps:
@@ -39,7 +39,7 @@ runs:
3939
distribution: ${{ inputs.java-early-access == 'true' && 'temurin' || (inputs.java-distribution || 'liberica') }}
4040
java-version: |
4141
${{ inputs.java-early-access == 'true' && format('{0}-ea', inputs.java-version) || inputs.java-version }}
42-
${{ inputs.java-toolchain == 'true' && '17' || '' }}
42+
${{ inputs.java-toolchain == 'true' && '23' || '' }}
4343
- name: Set Up Gradle With Read/Write Cache
4444
if: ${{ inputs.cache-read-only == 'false' }}
4545
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4.3.0

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ jobs:
1818
name: Windows
1919
java:
2020
- version: 17
21-
toolchain: false
21+
toolchain: true
2222
- version: 21
23-
toolchain: false
23+
toolchain: true
2424
- version: 22
25-
toolchain: false
26-
- version: 23
2725
toolchain: true
26+
- version: 23
27+
toolchain: false
2828
- version: 24
2929
early-access: true
3030
toolchain: true
3131
exclude:
3232
- os:
3333
name: Linux
3434
java:
35-
version: 17
35+
version: 23
3636
- os:
3737
name: ${{ github.repository == 'spring-projects/spring-boot-commercial' && 'Windows' }}
3838
steps:

.sdkmanrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Enable auto-env through the sdkman_auto_env config
22
# Add key=value pairs of SDKs to use below
3-
java=17.0.13-librca
3+
java=23.0.2-librca

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -218,21 +218,17 @@ private void configureJavaConventions(Project project) {
218218
if (!project.hasProperty("toolchainVersion")) {
219219
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
220220
javaPluginExtension.setSourceCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
221+
javaPluginExtension.setTargetCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
221222
}
222223
project.getTasks().withType(JavaCompile.class, (compile) -> {
223224
compile.getOptions().setEncoding("UTF-8");
225+
compile.getOptions().getRelease().set(17);
224226
List<String> args = compile.getOptions().getCompilerArgs();
225227
if (!args.contains("-parameters")) {
226228
args.add("-parameters");
227229
}
228-
if (project.hasProperty("toolchainVersion")) {
229-
compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
230-
compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
231-
}
232-
else if (buildingWithJava17(project)) {
233-
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
234-
"-Xlint:varargs"));
235-
}
230+
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
231+
"-Xlint:varargs"));
236232
});
237233
}
238234

buildSrc/src/main/java/org/springframework/boot/build/toolchain/ToolchainPlugin.java

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,21 +16,17 @@
1616

1717
package org.springframework.boot.build.toolchain;
1818

19-
import java.util.ArrayList;
20-
import java.util.Collections;
21-
import java.util.List;
22-
2319
import org.gradle.api.Plugin;
2420
import org.gradle.api.Project;
25-
import org.gradle.api.plugins.JavaPluginExtension;
2621
import org.gradle.api.tasks.testing.Test;
2722
import org.gradle.jvm.toolchain.JavaLanguageVersion;
28-
import org.gradle.jvm.toolchain.JavaToolchainSpec;
23+
import org.gradle.jvm.toolchain.JavaToolchainService;
2924

3025
/**
3126
* {@link Plugin} for customizing Gradle's toolchain support.
3227
*
3328
* @author Christoph Dreis
29+
* @author Andy Wilkinson
3430
*/
3531
public class ToolchainPlugin implements Plugin<Project> {
3632

@@ -52,11 +48,7 @@ private void configure(Project project, ToolchainExtension toolchain) {
5248
disableToolchainTasks(project);
5349
}
5450
else {
55-
JavaToolchainSpec toolchainSpec = project.getExtensions()
56-
.getByType(JavaPluginExtension.class)
57-
.getToolchain();
58-
toolchainSpec.getLanguageVersion().set(toolchain.getJavaVersion());
59-
configureTestToolchain(project, toolchain);
51+
configureTestToolchain(project, toolchain.getJavaVersion());
6052
}
6153
}
6254

@@ -70,9 +62,11 @@ private void disableToolchainTasks(Project project) {
7062
project.getTasks().withType(Test.class, (task) -> task.setEnabled(false));
7163
}
7264

73-
private void configureTestToolchain(Project project, ToolchainExtension toolchain) {
74-
List<String> jvmArgs = new ArrayList<>(toolchain.getTestJvmArgs().getOrElse(Collections.emptyList()));
75-
project.getTasks().withType(Test.class, (test) -> test.jvmArgs(jvmArgs));
65+
private void configureTestToolchain(Project project, JavaLanguageVersion toolchainVersion) {
66+
JavaToolchainService javaToolchains = project.getExtensions().getByType(JavaToolchainService.class);
67+
project.getTasks()
68+
.withType(Test.class, (test) -> test.getJavaLauncher()
69+
.set(javaToolchains.launcherFor((spec) -> spec.getLanguageVersion().set(toolchainVersion))));
7670
}
7771

7872
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/condition/ConditionalOnAvailableEndpointTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -324,6 +324,7 @@ static class DashedEndpoint {
324324

325325
}
326326

327+
@SuppressWarnings({ "deprecation", "removal" })
327328
@Endpoint(id = "disabledbutaccessible", enableByDefault = false)
328329
static class DisabledButAccessibleEndpoint {
329330

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/DisabledEndpoint.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
*
2424
* @author Stephane Nicoll
2525
*/
26+
@SuppressWarnings({ "deprecation", "removal" })
2627
@Endpoint(id = "disabled", enableByDefault = false)
2728
public class DisabledEndpoint {
2829

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/SimpleEndpoint3.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
*
2626
* @author Moritz Halbritter
2727
*/
28+
@SuppressWarnings({ "deprecation", "removal" })
2829
@Endpoint(id = "simple", enableByDefault = false)
2930
public class SimpleEndpoint3 {
3031

spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationsample/endpoint/SpecificEndpoint.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
*
2727
* @author Stephane Nicoll
2828
*/
29+
@SuppressWarnings({ "deprecation", "removal" })
2930
@WebEndpoint(id = "specific", enableByDefault = true)
3031
public class SpecificEndpoint {
3132

spring-boot-project/spring-boot-tools/spring-boot-loader-tools/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ sourceSets {
8484
}
8585
}
8686

87+
tasks.named("compileJava") {
88+
options.compilerArgs -= ['-Werror']
89+
}
90+
8791
plugins.withType(EclipsePlugin) {
8892
eclipse {
8993
classpath.file { merger ->

0 commit comments

Comments
 (0)