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:
|
||||
description: 'Java version to compile and test with'
|
||||
required: false
|
||||
default: '17'
|
||||
default: '24'
|
||||
publish:
|
||||
description: 'Whether to publish artifacts ready for deployment to Artifactory'
|
||||
required: false
|
||||
|
|
|
@ -23,7 +23,7 @@ inputs:
|
|||
java-version:
|
||||
description: 'Java version to use for the build'
|
||||
required: false
|
||||
default: '17'
|
||||
default: '24'
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
|
@ -39,7 +39,7 @@ runs:
|
|||
distribution: ${{ inputs.java-early-access == 'true' && 'temurin' || (inputs.java-distribution || 'liberica') }}
|
||||
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
|
||||
if: ${{ inputs.cache-read-only == 'false' }}
|
||||
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
||||
|
|
|
@ -18,21 +18,20 @@ jobs:
|
|||
name: Windows
|
||||
java:
|
||||
- version: 17
|
||||
toolchain: false
|
||||
toolchain: true
|
||||
- version: 21
|
||||
toolchain: false
|
||||
toolchain: true
|
||||
- version: 22
|
||||
toolchain: false
|
||||
toolchain: true
|
||||
- version: 23
|
||||
toolchain: true
|
||||
- version: 24
|
||||
early-access: true
|
||||
toolchain: true
|
||||
toolchain: false
|
||||
exclude:
|
||||
- os:
|
||||
name: Linux
|
||||
java:
|
||||
version: 17
|
||||
version: 24
|
||||
- os:
|
||||
name: ${{ github.repository == 'spring-projects/spring-boot-commercial' && 'Windows' }}
|
||||
steps:
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
# Enable auto-env through the sdkman_auto_env config
|
||||
# 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")) {
|
||||
JavaPluginExtension javaPluginExtension = project.getExtensions().getByType(JavaPluginExtension.class);
|
||||
javaPluginExtension.setSourceCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
|
||||
javaPluginExtension.setTargetCompatibility(JavaVersion.toVersion(SOURCE_AND_TARGET_COMPATIBILITY));
|
||||
}
|
||||
project.getTasks().withType(JavaCompile.class, (compile) -> {
|
||||
compile.getOptions().setEncoding("UTF-8");
|
||||
compile.getOptions().getRelease().set(17);
|
||||
List<String> args = compile.getOptions().getCompilerArgs();
|
||||
if (!args.contains("-parameters")) {
|
||||
args.add("-parameters");
|
||||
}
|
||||
if (project.hasProperty("toolchainVersion")) {
|
||||
compile.setSourceCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
|
||||
compile.setTargetCompatibility(SOURCE_AND_TARGET_COMPATIBILITY);
|
||||
}
|
||||
else if (buildingWithJava17(project)) {
|
||||
args.addAll(Arrays.asList("-Werror", "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
|
||||
"-Xlint:varargs"));
|
||||
}
|
||||
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) {
|
||||
project.getPlugins().apply(SpringJavaFormatPlugin.class);
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,21 +16,17 @@
|
|||
|
||||
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.Project;
|
||||
import org.gradle.api.plugins.JavaPluginExtension;
|
||||
import org.gradle.api.tasks.testing.Test;
|
||||
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.
|
||||
*
|
||||
* @author Christoph Dreis
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class ToolchainPlugin implements Plugin<Project> {
|
||||
|
||||
|
@ -52,11 +48,7 @@ public class ToolchainPlugin implements Plugin<Project> {
|
|||
disableToolchainTasks(project);
|
||||
}
|
||||
else {
|
||||
JavaToolchainSpec toolchainSpec = project.getExtensions()
|
||||
.getByType(JavaPluginExtension.class)
|
||||
.getToolchain();
|
||||
toolchainSpec.getLanguageVersion().set(toolchain.getJavaVersion());
|
||||
configureTestToolchain(project, toolchain);
|
||||
configureTestToolchain(project, toolchain.getJavaVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,9 +62,11 @@ public class ToolchainPlugin implements Plugin<Project> {
|
|||
project.getTasks().withType(Test.class, (task) -> task.setEnabled(false));
|
||||
}
|
||||
|
||||
private void configureTestToolchain(Project project, ToolchainExtension toolchain) {
|
||||
List<String> jvmArgs = new ArrayList<>(toolchain.getTestJvmArgs().getOrElse(Collections.emptyList()));
|
||||
project.getTasks().withType(Test.class, (test) -> test.jvmArgs(jvmArgs));
|
||||
private void configureTestToolchain(Project project, JavaLanguageVersion toolchainVersion) {
|
||||
JavaToolchainService javaToolchains = project.getExtensions().getByType(JavaToolchainService.class);
|
||||
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");
|
||||
* 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)
|
||||
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");
|
||||
* 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
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
@Endpoint(id = "disabled", enableByDefault = false)
|
||||
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");
|
||||
* 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
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
@Endpoint(id = "simple", enableByDefault = false)
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -26,6 +26,7 @@ import org.springframework.lang.Nullable;
|
|||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
@WebEndpoint(id = "specific", enableByDefault = true)
|
||||
public class SpecificEndpoint {
|
||||
|
||||
|
|
|
@ -84,6 +84,10 @@ sourceSets {
|
|||
}
|
||||
}
|
||||
|
||||
tasks.named("compileJava") {
|
||||
options.compilerArgs -= ['-Werror']
|
||||
}
|
||||
|
||||
plugins.withType(EclipsePlugin) {
|
||||
eclipse {
|
||||
classpath.file { merger ->
|
||||
|
|
Loading…
Reference in New Issue