From 853caf9a59b2c5da76f25a1466eae36917ce1a33 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 21 Jun 2023 10:36:38 +0100 Subject: [PATCH] Do not exclude DevTools from Maven AOT processing classpath When excluded from the AOT processing classpath, a reflection hint for DevTools' RestartScopeInitializer that's registered in spring.factories is not generated. When the native image is compiled we have no control over its classpath so DevTools is included. This causes a failure at runtime as RestartScopeInitializer cannot be loaded due to the missing reflection hint. Until we have control over the native image classpath, we need to include DevTools on the AOT processing classpath and then rely on DevTools disabling itself in a native image which it already does. Fixes gh-35853 --- .../src/main/java/org/test/SampleApplication.java | 1 - .../java/org/springframework/boot/maven/ProcessAotMojo.java | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/aot-development-only-exclusions/src/main/java/org/test/SampleApplication.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/aot-development-only-exclusions/src/main/java/org/test/SampleApplication.java index b8430b02cb..cd19b00cf6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/aot-development-only-exclusions/src/main/java/org/test/SampleApplication.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/aot-development-only-exclusions/src/main/java/org/test/SampleApplication.java @@ -25,7 +25,6 @@ import org.springframework.util.ClassUtils; public class SampleApplication { public static void main(String[] args) { - Assert.state(!ClassUtils.isPresent("org.springframework.boot.devtools.autoconfigure.DevToolsProperties", null), "Should not have devtools"); Assert.state(!ClassUtils.isPresent("org.springframework.boot.docker.compose.core.DockerCompose", null), "Should not have docker-compose"); SpringApplication.run(SampleApplication.class, args); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java index 3dd7a525f5..f5f3f2837b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/ProcessAotMojo.java @@ -111,8 +111,7 @@ public class ProcessAotMojo extends AbstractAotMojo { private URL[] getClassPath() throws Exception { File[] directories = new File[] { this.classesDirectory, this.generatedClasses }; - return getClassPath(directories, new ExcludeTestScopeArtifactFilter(), DEVTOOLS_EXCLUDE_FILTER, - DOCKER_COMPOSE_EXCLUDE_FILTER); + return getClassPath(directories, new ExcludeTestScopeArtifactFilter(), DOCKER_COMPOSE_EXCLUDE_FILTER); } private RunArguments resolveArguments() {