Compile project with Java 24 and '-release' Java 17
Closes gh-45472
This commit is contained in:
parent
af220127d0
commit
6e2049eb92
|
@ -35,7 +35,7 @@ inputs:
|
||||||
java-version:
|
java-version:
|
||||||
description: 'Java version to compile and test with'
|
description: 'Java version to compile and test with'
|
||||||
required: false
|
required: false
|
||||||
default: '17'
|
default: '24'
|
||||||
publish:
|
publish:
|
||||||
description: 'Whether to publish artifacts ready for deployment to Artifactory'
|
description: 'Whether to publish artifacts ready for deployment to Artifactory'
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -23,7 +23,7 @@ inputs:
|
||||||
java-version:
|
java-version:
|
||||||
description: 'Java version to use for the build'
|
description: 'Java version to use for the build'
|
||||||
required: false
|
required: false
|
||||||
default: '17'
|
default: '24'
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
@ -39,7 +39,7 @@ runs:
|
||||||
distribution: ${{ inputs.java-early-access == 'true' && 'temurin' || (inputs.java-distribution || 'liberica') }}
|
distribution: ${{ inputs.java-early-access == 'true' && 'temurin' || (inputs.java-distribution || 'liberica') }}
|
||||||
java-version: |
|
java-version: |
|
||||||
${{ inputs.java-early-access == 'true' && format('{0}-ea', inputs.java-version) || inputs.java-version }}
|
${{ inputs.java-early-access == 'true' && format('{0}-ea', inputs.java-version) || inputs.java-version }}
|
||||||
${{ inputs.java-toolchain == 'true' && '17' || '' }}
|
${{ inputs.java-toolchain == 'true' && '24' || '' }}
|
||||||
- name: Set Up Gradle With Read/Write Cache
|
- name: Set Up Gradle With Read/Write Cache
|
||||||
if: ${{ inputs.cache-read-only == 'false' }}
|
if: ${{ inputs.cache-read-only == 'false' }}
|
||||||
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
||||||
|
|
|
@ -18,21 +18,20 @@ jobs:
|
||||||
name: Windows
|
name: Windows
|
||||||
java:
|
java:
|
||||||
- version: 17
|
- version: 17
|
||||||
toolchain: false
|
toolchain: true
|
||||||
- version: 21
|
- version: 21
|
||||||
toolchain: false
|
toolchain: true
|
||||||
- version: 22
|
- version: 22
|
||||||
toolchain: false
|
toolchain: true
|
||||||
- version: 23
|
- version: 23
|
||||||
toolchain: true
|
toolchain: true
|
||||||
- version: 24
|
- version: 24
|
||||||
early-access: true
|
toolchain: false
|
||||||
toolchain: true
|
|
||||||
exclude:
|
exclude:
|
||||||
- os:
|
- os:
|
||||||
name: Linux
|
name: Linux
|
||||||
java:
|
java:
|
||||||
version: 17
|
version: 24
|
||||||
- os:
|
- os:
|
||||||
name: ${{ github.repository == 'spring-projects/spring-boot-commercial' && 'Windows' }}
|
name: ${{ github.repository == 'spring-projects/spring-boot-commercial' && 'Windows' }}
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
# Enable auto-env through the sdkman_auto_env config
|
# Enable auto-env through the sdkman_auto_env config
|
||||||
# Add key=value pairs of SDKs to use below
|
# Add key=value pairs of SDKs to use below
|
||||||
java=17.0.15-librca
|
java=24.0.1-librca
|
||||||
|
|
|
@ -235,28 +235,20 @@ class JavaConventions {
|
||||||
if (!project.hasProperty("toolchainVersion")) {
|
if (!project.hasProperty("toolchainVersion")) {
|
||||||
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
|
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||||
javaPluginExtension.setSourceCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
|
javaPluginExtension.setSourceCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
|
||||||
|
javaPluginExtension.setTargetCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
|
||||||
}
|
}
|
||||||
project.getTasks().withType(JavaCompile.class, (compile) -> {
|
project.getTasks().withType(JavaCompile.class, (compile) -> {
|
||||||
compile.getOptions().setEncoding("UTF-8");
|
compile.getOptions().setEncoding("UTF-8");
|
||||||
|
compile.getOptions().getRelease().set(17);
|
||||||
List<String> args = compile.getOptions().getCompilerArgs();
|
List<String> args = compile.getOptions().getCompilerArgs();
|
||||||
if (!args.contains("-parameters")) {
|
if (!args.contains("-parameters")) {
|
||||||
args.add("-parameters");
|
args.add("-parameters");
|
||||||
}
|
}
|
||||||
if (project.hasProperty("toolchainVersion")) {
|
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
|
||||||
compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
|
"-Xlint:varargs"));
|
||||||
compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
|
|
||||||
}
|
|
||||||
else if (buildingWithJava17(project)) {
|
|
||||||
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
|
|
||||||
"-Xlint:varargs"));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean buildingWithJava17(Project project) {
|
|
||||||
return !project.hasProperty("toolchainVersion") && JavaVersion.current() == JavaVersion.VERSION_17;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void configureSpringJavaFormat(Project project) {
|
private void configureSpringJavaFormat(Project project) {
|
||||||
project.getPlugins().apply(SpringJavaFormatPlugin.class);
|
project.getPlugins().apply(SpringJavaFormatPlugin.class);
|
||||||
project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8"));
|
project.getTasks().withType(Format.class, (Format) -> Format.setEncoding("UTF-8"));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,21 +16,17 @@
|
||||||
|
|
||||||
package org.springframework.boot.build.toolchain;
|
package org.springframework.boot.build.toolchain;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gradle.api.Plugin;
|
import org.gradle.api.Plugin;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.plugins.JavaPluginExtension;
|
|
||||||
import org.gradle.api.tasks.testing.Test;
|
import org.gradle.api.tasks.testing.Test;
|
||||||
import org.gradle.jvm.toolchain.JavaLanguageVersion;
|
import org.gradle.jvm.toolchain.JavaLanguageVersion;
|
||||||
import org.gradle.jvm.toolchain.JavaToolchainSpec;
|
import org.gradle.jvm.toolchain.JavaToolchainService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Plugin} for customizing Gradle's toolchain support.
|
* {@link Plugin} for customizing Gradle's toolchain support.
|
||||||
*
|
*
|
||||||
* @author Christoph Dreis
|
* @author Christoph Dreis
|
||||||
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
public class ToolchainPlugin implements Plugin<Project> {
|
public class ToolchainPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
|
@ -52,11 +48,7 @@ public class ToolchainPlugin implements Plugin<Project> {
|
||||||
disableToolchainTasks(project);
|
disableToolchainTasks(project);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JavaToolchainSpec toolchainSpec = project.getExtensions()
|
configureTestToolchain(project, toolchain.getJavaVersion());
|
||||||
.getByType(JavaPluginExtension.class)
|
|
||||||
.getToolchain();
|
|
||||||
toolchainSpec.getLanguageVersion().set(toolchain.getJavaVersion());
|
|
||||||
configureTestToolchain(project, toolchain);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +62,11 @@ public class ToolchainPlugin implements Plugin<Project> {
|
||||||
project.getTasks().withType(Test.class, (task) -> task.setEnabled(false));
|
project.getTasks().withType(Test.class, (task) -> task.setEnabled(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureTestToolchain(Project project, ToolchainExtension toolchain) {
|
private void configureTestToolchain(Project project, JavaLanguageVersion toolchainVersion) {
|
||||||
List<String> jvmArgs = new ArrayList<>(toolchain.getTestJvmArgs().getOrElse(Collections.emptyList()));
|
JavaToolchainService javaToolchains = project.getExtensions().getByType(JavaToolchainService.class);
|
||||||
project.getTasks().withType(Test.class, (test) -> test.jvmArgs(jvmArgs));
|
project.getTasks()
|
||||||
|
.withType(Test.class, (test) -> test.getJavaLauncher()
|
||||||
|
.set(javaToolchains.launcherFor((spec) -> spec.getLanguageVersion().set(toolchainVersion))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -324,6 +324,7 @@ class ConditionalOnAvailableEndpointTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "deprecation", "removal" })
|
||||||
@Endpoint(id = "disabledbutaccessible", enableByDefault = false)
|
@Endpoint(id = "disabledbutaccessible", enableByDefault = false)
|
||||||
static class DisabledButAccessibleEndpoint {
|
static class DisabledButAccessibleEndpoint {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -23,6 +23,7 @@ import org.springframework.boot.configurationsample.Endpoint;
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "deprecation", "removal" })
|
||||||
@Endpoint(id = "disabled", enableByDefault = false)
|
@Endpoint(id = "disabled", enableByDefault = false)
|
||||||
public class DisabledEndpoint {
|
public class DisabledEndpoint {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2024 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -25,6 +25,7 @@ import org.springframework.boot.configurationsample.ReadOperation;
|
||||||
*
|
*
|
||||||
* @author Moritz Halbritter
|
* @author Moritz Halbritter
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "deprecation", "removal" })
|
||||||
@Endpoint(id = "simple", enableByDefault = false)
|
@Endpoint(id = "simple", enableByDefault = false)
|
||||||
public class SimpleEndpoint3 {
|
public class SimpleEndpoint3 {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2025 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -26,6 +26,7 @@ import org.springframework.lang.Nullable;
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({ "deprecation", "removal" })
|
||||||
@WebEndpoint(id = "specific", enableByDefault = true)
|
@WebEndpoint(id = "specific", enableByDefault = true)
|
||||||
public class SpecificEndpoint {
|
public class SpecificEndpoint {
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,10 @@ sourceSets {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named("compileJava") {
|
||||||
|
options.compilerArgs -= ['-Werror']
|
||||||
|
}
|
||||||
|
|
||||||
plugins.withType(EclipsePlugin) {
|
plugins.withType(EclipsePlugin) {
|
||||||
eclipse {
|
eclipse {
|
||||||
classpath.file { merger ->
|
classpath.file { merger ->
|
||||||
|
|
Loading…
Reference in New Issue