Skip to content

Commit 80e8ab8

Browse files
committed
Support commercial repositories in effective BOM and Ivy
Update `BomExtension` to resolve '{spring.mavenRepositories}' and add credentials to `ivysettings.xml` and `settings.xml`. Closes gh-44050
1 parent fd51806 commit 80e8ab8

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

buildSrc/src/main/java/org/springframework/boot/build/bom/BomExtension.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.w3c.dom.NodeList;
6060

6161
import org.springframework.boot.build.DeployedPlugin;
62+
import org.springframework.boot.build.RepositoryTransformersExtension;
6263
import org.springframework.boot.build.bom.Library.Exclusion;
6364
import org.springframework.boot.build.bom.Library.Group;
6465
import org.springframework.boot.build.bom.Library.LibraryVersion;
@@ -132,6 +133,8 @@ public void library(String name, String version, Action<LibraryHandler> action)
132133

133134
public void effectiveBomArtifact() {
134135
Configuration effectiveBomConfiguration = this.project.getConfigurations().create("effectiveBom");
136+
RepositoryTransformersExtension repositoryTransformers = this.project.getExtensions()
137+
.getByType(RepositoryTransformersExtension.class);
135138
this.project.getTasks()
136139
.matching((task) -> task.getName().equals(DeployedPlugin.GENERATE_POM_TASK_NAME))
137140
.all((task) -> {
@@ -144,8 +147,10 @@ public void effectiveBomArtifact() {
144147
sync.dependsOn(task);
145148
sync.setDestinationDir(generatedBomDir);
146149
sync.from(((GenerateMavenPom) task).getDestination(), (pom) -> pom.rename((name) -> "pom.xml"));
147-
sync.from(this.project.getResources().getText().fromString(loadSettingsXml()),
148-
(settingsXml) -> settingsXml.rename((name) -> "settings.xml"));
150+
sync.from(this.project.getResources().getText().fromString(loadSettingsXml()), (settingsXml) -> {
151+
settingsXml.rename((name) -> "settings.xml");
152+
settingsXml.filter(repositoryTransformers.mavenSettings());
153+
});
149154
});
150155
File effectiveBom = this.project.getLayout()
151156
.getBuildDirectory()

buildSrc/src/main/resources/effective-bom-settings.xml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,7 @@
77
<activeByDefault>true</activeByDefault>
88
</activation>
99
<repositories>
10-
<repository>
11-
<id>spring-snapshot</id>
12-
<url>https://repo.spring.io/snapshot</url>
13-
<snapshots>
14-
<enabled>true</enabled>
15-
</snapshots>
16-
</repository>
17-
<repository>
18-
<id>spring-milestone</id>
19-
<url>https://repo.spring.io/milestone</url>
20-
</repository>
10+
<!-- {spring.mavenRepositories} -->
2111
</repositories>
2212
</profile>
2313
</profiles>

spring-boot-project/spring-boot-tools/spring-boot-antlib/src/it/sample/ivysettings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
<!-- {spring.mavenRepositories} -->
1212
</chain>
1313
</resolvers>
14+
<credentials host="${env.COMMERCIAL_RELEASE_REPO_URL}" username="${env.COMMERCIAL_REPO_USERNAME}" passwd="${env.COMMERCIAL_REPO_PASSWORD}"/>
15+
<credentials host="${env.COMMERCIAL_SNAPSHOT_REPO_URL}" username="${env.COMMERCIAL_REPO_USERNAME}" passwd="${env.COMMERCIAL_REPO_PASSWORD}"/>
1416
</ivysettings>
15-

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/projects/settings.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<settings>
33
<localRepository>@localRepositoryPath@</localRepository>
4+
<servers>
5+
<server>
6+
<id>spring-commercial-release</id>
7+
<username>${env.COMMERCIAL_REPO_USERNAME}</username>
8+
<password>${env.COMMERCIAL_REPO_PASSWORD}</password>
9+
</server>
10+
<server>
11+
<id>spring-commercial-snapshot</id>
12+
<username>${env.COMMERCIAL_REPO_USERNAME}</username>
13+
<password>${env.COMMERCIAL_REPO_PASSWORD}</password>
14+
</server>
15+
</servers>
416
<profiles>
517
<profile>
618
<id>it-repo</id>

0 commit comments

Comments
 (0)