From 4498b46512aeec0654b022d058853800ca645fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Thu, 11 Sep 2025 10:51:31 +0200 Subject: [PATCH] Polish "Exclude spring-boot-devtools from AOT processing with Maven" See gh-46533 --- .../springframework/boot/maven/AotTests.java | 44 +++++++++---------- .../projects/aot-exclude-devtools/pom.xml | 6 --- .../aot-test-exclude-devtools/pom.xml | 7 +-- 3 files changed, 23 insertions(+), 34 deletions(-) diff --git a/build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AotTests.java b/build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AotTests.java index 93664d0acb9..6a16e4d9905 100644 --- a/build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AotTests.java +++ b/build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AotTests.java @@ -166,6 +166,17 @@ class AotTests { }); } + @TestTemplate + void whenAotRunsWithDevtoolsInClasspathItIsExcluded(MavenBuild mavenBuild) { + mavenBuild.project("aot-exclude-devtools").goals("package").execute((project) -> { + Path aotDirectory = project.toPath().resolve("target/spring-aot/main"); + assertThat(aotDirectory).exists(); + Path sourcesDirectory = aotDirectory.resolve("sources"); + assertThat(sourcesDirectory).exists(); + assertThat(collectRelativePaths(sourcesDirectory)).isNotEmpty(); + }); + } + @TestTemplate void whenAotTestRunsSourcesAndResourcesAreGenerated(MavenBuild mavenBuild) { mavenBuild.project("aot-test").goals("test").execute((project) -> { @@ -180,6 +191,17 @@ class AotTests { }); } + @TestTemplate + void whenTestAotRunsWithDevtoolsInClasspathItIsExcluded(MavenBuild mavenBuild) { + mavenBuild.project("aot-test-exclude-devtools").goals("process-test-classes").execute((project) -> { + Path aotDirectory = project.toPath().resolve("target/spring-aot/test"); + assertThat(aotDirectory).exists(); + Path sourcesDirectory = aotDirectory.resolve("sources"); + assertThat(sourcesDirectory).exists(); + assertThat(collectRelativePaths(sourcesDirectory)).isNotEmpty(); + }); + } + List collectRelativePaths(Path sourceDirectory) { try (Stream pathStream = Files.walk(sourceDirectory)) { return pathStream.filter(Files::isRegularFile) @@ -195,26 +217,4 @@ class AotTests { return contentOf(new File(project, "target/build.log")); } - @TestTemplate - void whenAotRunsWithDevtoolsInClasspathItIsExcluded(MavenBuild mavenBuild) { - mavenBuild.project("aot-exclude-devtools").goals("package").execute((project) -> { - Path aotDirectory = project.toPath().resolve("target/spring-aot/main"); - assertThat(aotDirectory).exists(); - Path sourcesDirectory = aotDirectory.resolve("sources"); - assertThat(sourcesDirectory).exists(); - assertThat(collectRelativePaths(sourcesDirectory)).isNotEmpty(); - }); - } - - @TestTemplate - void whenTestAotRunsWithDevtoolsInClasspathItIsExcluded(MavenBuild mavenBuild) { - mavenBuild.project("aot-test-exclude-devtools").goals("process-test-classes").execute((project) -> { - Path aotDirectory = project.toPath().resolve("target/spring-aot/test"); - assertThat(aotDirectory).exists(); - Path sourcesDirectory = aotDirectory.resolve("sources"); - assertThat(sourcesDirectory).exists(); - assertThat(collectRelativePaths(sourcesDirectory)).isNotEmpty(); - }); - } - } diff --git a/build-plugin/spring-boot-maven-plugin/src/intTest/projects/aot-exclude-devtools/pom.xml b/build-plugin/spring-boot-maven-plugin/src/intTest/projects/aot-exclude-devtools/pom.xml index 27c15bf381d..4c7520628f4 100644 --- a/build-plugin/spring-boot-maven-plugin/src/intTest/projects/aot-exclude-devtools/pom.xml +++ b/build-plugin/spring-boot-maven-plugin/src/intTest/projects/aot-exclude-devtools/pom.xml @@ -38,11 +38,5 @@ @project.version@ true - - jakarta.servlet - jakarta.servlet-api - @jakarta-servlet.version@ - provided - diff --git a/build-plugin/spring-boot-maven-plugin/src/intTest/projects/aot-test-exclude-devtools/pom.xml b/build-plugin/spring-boot-maven-plugin/src/intTest/projects/aot-test-exclude-devtools/pom.xml index 69276c03b23..0d361d64ada 100644 --- a/build-plugin/spring-boot-maven-plugin/src/intTest/projects/aot-test-exclude-devtools/pom.xml +++ b/build-plugin/spring-boot-maven-plugin/src/intTest/projects/aot-test-exclude-devtools/pom.xml @@ -38,6 +38,7 @@ @project.version@ true + org.springframework.boot spring-boot-test @@ -50,11 +51,5 @@ @junit-jupiter.version@ test - - jakarta.servlet - jakarta.servlet-api - @jakarta-servlet.version@ - provided -