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
This commit is contained in:
Stéphane Nicoll
2026-08-04 15:41:43 +02:00
parent db5ccf4da3
commit 4c8de39294
2 changed files with 15 additions and 3 deletions
@@ -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"])
}
}
@@ -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);