mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Raise GraalVM baseline to 25
This also removes the 'requiredVersion' setting from the native-maven-plugin configuration, as this is deprecated in the native build tools. Close gh-47433
This commit is contained in:
-1
@@ -87,7 +87,6 @@ When the {url-native-build-tools-docs-gradle-plugin}[GraalVM Native Image plugin
|
||||
. Adds the output of the `aot` source set to the classpath of the `main` GraalVM native binary.
|
||||
. Adds the output of the `aotTest` source set to the classpath of the `test` GraalVM native binary.
|
||||
. Configures the GraalVM extension to disable Toolchain detection.
|
||||
. Configures each GraalVM native binary to require GraalVM 22.3 or later.
|
||||
. Configures the `bootJar` task to include the reachability metadata produced by the `collectReachabilityMetadata` task in its jar.
|
||||
. Configures the `bootJar` task to add the `Spring-Boot-Native-Processed: true` manifest entry.
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.springframework.boot.context.properties.bind.Binder;
|
||||
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
|
||||
import org.springframework.boot.convert.ApplicationConversionService;
|
||||
import org.springframework.boot.env.DefaultPropertiesPropertySource;
|
||||
import org.springframework.boot.system.JavaVersion;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
@@ -418,6 +419,9 @@ public class SpringApplication {
|
||||
}
|
||||
|
||||
private void addAotGeneratedInitializerIfNecessary(List<ApplicationContextInitializer<?>> initializers) {
|
||||
if (NativeDetector.inNativeImage()) {
|
||||
checkNativeImageVersion();
|
||||
}
|
||||
if (AotDetector.useGeneratedArtifacts()) {
|
||||
List<ApplicationContextInitializer<?>> aotInitializers = new ArrayList<>(
|
||||
initializers.stream().filter(AotApplicationContextInitializer.class::isInstance).toList());
|
||||
@@ -434,6 +438,15 @@ public class SpringApplication {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNativeImageVersion() {
|
||||
JavaVersion minRequiredJavaVersion = JavaVersion.TWENTY_FIVE;
|
||||
if (JavaVersion.getJavaVersion().isOlderThan(minRequiredJavaVersion)) {
|
||||
throw new NativeImageRequirementsNotMetException(
|
||||
"Native Image requirements not met, please upgrade it. Native Image must support at least Java %s"
|
||||
.formatted(minRequiredJavaVersion));
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshContext(ConfigurableApplicationContext context) {
|
||||
if (this.properties.isRegisterShutdownHook()) {
|
||||
shutdownHook.registerApplicationContext(context);
|
||||
@@ -1645,6 +1658,21 @@ public class SpringApplication {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception which is thrown if GraalVM's native-image requirements aren't met.
|
||||
*/
|
||||
private static final class NativeImageRequirementsNotMetException extends RuntimeException {
|
||||
|
||||
/**
|
||||
* Creates a new {@link NativeImageRequirementsNotMetException} instance.
|
||||
* @param message the message
|
||||
*/
|
||||
private NativeImageRequirementsNotMetException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link SpringApplicationHook} decorator that ensures the hook is only used once.
|
||||
*/
|
||||
|
||||
+5
-5
@@ -175,8 +175,8 @@ Get SDKMAN! from https://sdkman.io and install the Liberica GraalVM distribution
|
||||
|
||||
[source,shell,subs="verbatim,attributes"]
|
||||
----
|
||||
$ sdk install java {version-graal}.r17-nik
|
||||
$ sdk use java {version-graal}.r17-nik
|
||||
$ sdk install java 25.r25-nik
|
||||
$ sdk use java 25.r25-nik
|
||||
----
|
||||
|
||||
Verify that the correct version has been configured by checking the output of `java -version`:
|
||||
@@ -184,9 +184,9 @@ Verify that the correct version has been configured by checking the output of `j
|
||||
[source,shell,subs="verbatim,attributes"]
|
||||
----
|
||||
$ java -version
|
||||
openjdk version "17.0.5" 2022-10-18 LTS
|
||||
OpenJDK Runtime Environment GraalVM 22.3.0 (build 17.0.5+8-LTS)
|
||||
OpenJDK 64-Bit Server VM GraalVM 22.3.0 (build 17.0.5+8-LTS, mixed mode)
|
||||
openjdk version "25" 2025-09-16 LTS
|
||||
OpenJDK Runtime Environment Liberica-NIK-25.0.0-1 (build 25+37-LTS)
|
||||
OpenJDK 64-Bit Server VM Liberica-NIK-25.0.0-1 (build 25+37-LTS, mixed mode, sharing)
|
||||
----
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
|
||||
assertjVersion=3.27.6
|
||||
checkstyleToolVersion=10.12.4
|
||||
commonsCodecVersion=1.19.0
|
||||
graalVersion=22.3
|
||||
graalVersion=25
|
||||
hamcrestVersion=3.0
|
||||
jackson2Version=2.20.0
|
||||
jacksonVersion=3.0.0
|
||||
|
||||
@@ -297,7 +297,6 @@ publishing.publications.withType(MavenPublication) {
|
||||
delegate.artifactId('native-maven-plugin')
|
||||
configuration {
|
||||
delegate.classesDirectory('${project.build.outputDirectory}')
|
||||
delegate.requiredVersion('22.3')
|
||||
exclusions {
|
||||
exclusion {
|
||||
delegate.groupId('org.springframework.boot')
|
||||
@@ -347,7 +346,6 @@ publishing.publications.withType(MavenPublication) {
|
||||
delegate.artifactId('native-maven-plugin')
|
||||
configuration {
|
||||
delegate.classesDirectory('${project.build.outputDirectory}')
|
||||
delegate.requiredVersion('22.3')
|
||||
exclusions {
|
||||
exclusion {
|
||||
delegate.groupId('org.springframework.boot')
|
||||
|
||||
Reference in New Issue
Block a user