mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Update the build for release train participation
Closes gh-51163
This commit is contained in:
@@ -12,6 +12,11 @@
|
||||
<username>${env.COMMERCIAL_REPO_USERNAME}</username>
|
||||
<password>${env.COMMERCIAL_REPO_PASSWORD}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>spring-release-train</id>
|
||||
<username>${env.RELEASE_TRAIN_MAVEN_REPOSITORY_USERNAME}</username>
|
||||
<password>${env.RELEASE_TRAIN_MAVEN_REPOSITORY_PASSWORD}</password>
|
||||
</server>
|
||||
</servers>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
||||
@@ -104,6 +104,7 @@ class SpringRepositoriesExtension {
|
||||
}
|
||||
|
||||
private void addRepositories(version, action) {
|
||||
addReleaseTrainRepositoryIfNecessary("spring-release-train", action)
|
||||
addCommercialRepositoryIfNecessary("release", false, "/spring-enterprise-maven-prod-local", action)
|
||||
if (version.endsWith("-SNAPSHOT")) {
|
||||
addCommercialRepositoryIfNecessary("snapshot", true, "/spring-enterprise-maven-dev-local", action)
|
||||
@@ -132,6 +133,21 @@ class SpringRepositoriesExtension {
|
||||
})
|
||||
}
|
||||
|
||||
private void addReleaseTrainRepositoryIfNecessary(id, action) {
|
||||
def url = this.environment.apply("RELEASE_TRAIN_MAVEN_REPOSITORY_URL")
|
||||
if (url != null) {
|
||||
def username = this.environment.apply("RELEASE_TRAIN_MAVEN_REPOSITORY_USERNAME")
|
||||
def password = this.environment.apply("RELEASE_TRAIN_MAVEN_REPOSITORY_PASSWORD")
|
||||
addRepository(id, false, url, { maven ->
|
||||
maven.credentials { credentials ->
|
||||
credentials.setUsername(username)
|
||||
credentials.setPassword(password)
|
||||
}
|
||||
action(maven)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private void addRepository(name, snapshot, url, action) {
|
||||
this.repositories.maven { maven ->
|
||||
maven.setName(name)
|
||||
|
||||
+28
-6
@@ -43,6 +43,8 @@ public class RepositoryTransformersExtension {
|
||||
|
||||
private static final String REPOSITORIES_MARKER = "{spring.mavenRepositories}";
|
||||
|
||||
private static final String PLUGIN_REPOSITORIES_MARKER = "{spring.mavenPluginRepositories}";
|
||||
|
||||
private final Project project;
|
||||
|
||||
@Inject
|
||||
@@ -67,13 +69,33 @@ public class RepositoryTransformersExtension {
|
||||
getSpringRepositories().forEach((repository) -> {
|
||||
if (repository.getName().startsWith("spring-commercial-")) {
|
||||
String host = repository.getUrl().getHost();
|
||||
hostCredentials.put(host,
|
||||
new MavenCredential("${env.COMMERCIAL_REPO_USERNAME}", "${env.COMMERCIAL_REPO_PASSWORD}"));
|
||||
hostCredentials.put(host, new MavenCredential("${env.COMMERCIAL_REPO_USERNAME}",
|
||||
"${env.COMMERCIAL_REPO_PASSWORD}", "Artifactory Realm"));
|
||||
}
|
||||
else if (repository.getName().equals("spring-release-train")) {
|
||||
String host = repository.getUrl().getHost();
|
||||
hostCredentials.put(host, new MavenCredential("${env.RELEASE_TRAIN_MAVEN_REPOSITORY_USERNAME}",
|
||||
"${env.RELEASE_TRAIN_MAVEN_REPOSITORY_PASSWORD}", "GitHub Package Registry"));
|
||||
}
|
||||
});
|
||||
return transform(line, hostCredentials.entrySet(), (entry,
|
||||
indent) -> "%s<credentials host=\"%s\" realm=\"Artifactory Realm\" username=\"%s\" passwd=\"%s\" />%n"
|
||||
.formatted(indent, entry.getKey(), entry.getValue().username(), entry.getValue().password()));
|
||||
return transform(line, hostCredentials.entrySet(),
|
||||
(entry, indent) -> "%s<credentials host=\"%s\" realm=\"%s\" username=\"%s\" passwd=\"%s\" />%n"
|
||||
.formatted(indent, entry.getKey(), entry.getValue().realm(), entry.getValue().username(),
|
||||
entry.getValue().password()));
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
public Transformer<String, String> mavenSettings() {
|
||||
return this::transformMavenSettings;
|
||||
}
|
||||
|
||||
private String transformMavenSettings(String line) {
|
||||
if (line.contains(REPOSITORIES_MARKER)) {
|
||||
return transformMavenRepositories(line, false);
|
||||
}
|
||||
if (line.contains(PLUGIN_REPOSITORIES_MARKER)) {
|
||||
return transformMavenRepositories(line, true);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
@@ -141,7 +163,7 @@ public class RepositoryTransformersExtension {
|
||||
project.getExtensions().create("springRepositoryTransformers", RepositoryTransformersExtension.class, project);
|
||||
}
|
||||
|
||||
record MavenCredential(String username, String password) {
|
||||
record MavenCredential(String username, String password, String realm) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user