From 4c8de39294362ff6f191783f46d6ffa3c7e57b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Tue, 4 Aug 2026 15:41:43 +0200 Subject: [PATCH] Restore additional repositories for docker tests This commit reverts partially what was done in gh-49397 to let docker tests have access to additional maven repositories. Unfortunately, maven build executions with the Spring Boot Maven Plugin do not use the BOM for dependency management. As such, if one of the dependency requires a dependency that has not been prepared in the local repository, it will need to be able to download it from the relevant repository. This is the case with spring-core that the maven plugin depends on when Spring Framework and Spring Boot do not use the same Micrometer version: the build prepares the version that Spring Boot uses, but the build execution attempts to download the one that Spring Framework relies on. Closes gh-51266 --- build-plugin/spring-boot-maven-plugin/build.gradle | 10 ++++++++-- .../org/springframework/boot/maven/MavenBuild.java | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/build-plugin/spring-boot-maven-plugin/build.gradle b/build-plugin/spring-boot-maven-plugin/build.gradle index 695639377b3..3bf086c05c2 100644 --- a/build-plugin/spring-boot-maven-plugin/build.gradle +++ b/build-plugin/spring-boot-maven-plugin/build.gradle @@ -108,15 +108,21 @@ tasks.named("checkCompileClasspathForProhibitedDependencies") { permittedGroups = ["javax.inject"] } +tasks.register("copySettingsXml", Copy) { + from file("src/intTest/projects/settings.xml") + into layout.buildDirectory.dir("generated-resources/settings") + filter(springRepositoryTransformers.mavenSettings()) +} + sourceSets { main { output.dir(layout.buildDirectory.dir("generated/resources/xsd"), builtBy: "xsdResources") } intTest { - output.dir(layout.buildDirectory.dir("generated-resources"), builtBy: ["extractVersionProperties"]) + output.dir(layout.buildDirectory.dir("generated-resources"), builtBy: ["extractVersionProperties", "copySettingsXml"]) } dockerTest { - output.dir(layout.buildDirectory.dir("generated-resources"), builtBy: "extractVersionProperties") + output.dir(layout.buildDirectory.dir("generated-resources"), builtBy: ["extractVersionProperties", "copySettingsXml"]) } } diff --git a/build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/MavenBuild.java b/build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/MavenBuild.java index 0a781e72ce3..e662a3a50cb 100644 --- a/build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/MavenBuild.java +++ b/build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/MavenBuild.java @@ -69,6 +69,8 @@ class MavenBuild { private final Properties properties = new Properties(); + private String root = "intTest"; + private @Nullable ProjectCallback preparation; private @Nullable File projectDir; @@ -102,6 +104,7 @@ class MavenBuild { } MavenBuild project(String root, String project) { + this.root = root; this.projectDir = new File("src/" + root + "/projects/" + project); return this; } @@ -163,7 +166,10 @@ class MavenBuild { } }); - String settingsXml = Files.readString(Paths.get("src", "intTest", "projects", "settings.xml")) + Path settingsXmlPath = "dockerTest".equals(this.root) + ? Paths.get("build", "generated-resources", "settings", "settings.xml") + : Paths.get("src", "intTest", "projects", "settings.xml"); + String settingsXml = Files.readString(settingsXmlPath) .replace("@localCentralUrl@", new File("build/test-maven-repository").toURI().toURL().toString()) .replace("@localRepositoryPath@", new File("build/local-maven-repository").getAbsolutePath()); Files.writeString(destination.resolve("settings.xml"), settingsXml, StandardOpenOption.CREATE_NEW);