diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index da60b4197b..ab6ceab1d0 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -13,6 +13,16 @@ repositories { gradlePluginPortal() mavenCentral() maven { url = 'https://repo.spring.io/snapshot' } + if (System.getenv("RELEASE_TRAIN_MAVEN_REPOSITORY_URL") != null) { + maven { + name = "Release Train" + url = System.getenv("RELEASE_TRAIN_MAVEN_REPOSITORY_URL") + credentials { + username = System.getenv("RELEASE_TRAIN_MAVEN_REPOSITORY_USERNAME") + password = System.getenv("RELEASE_TRAIN_MAVEN_REPOSITORY_PASSWORD") + } + } + } } sourceSets { diff --git a/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy b/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy index 5bd68fb172..268b52a0be 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy @@ -43,6 +43,16 @@ class RepositoryConventionPlugin implements Plugin { } } mavenCentral() + if (System.getenv("RELEASE_TRAIN_MAVEN_REPOSITORY_URL") != null) { + maven { + name = "Release Train" + url = System.getenv("RELEASE_TRAIN_MAVEN_REPOSITORY_URL") + credentials { + username = System.getenv("RELEASE_TRAIN_MAVEN_REPOSITORY_USERNAME") + password = System.getenv("RELEASE_TRAIN_MAVEN_REPOSITORY_PASSWORD") + } + } + } if (isSnapshot) { maven { name = 'artifactory-snapshot' diff --git a/buildSrc/src/main/java/org/springframework/gradle/maven/MavenPublishingConventionsPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/maven/MavenPublishingConventionsPlugin.java index d82b6d9436..dd36daa4e8 100644 --- a/buildSrc/src/main/java/org/springframework/gradle/maven/MavenPublishingConventionsPlugin.java +++ b/buildSrc/src/main/java/org/springframework/gradle/maven/MavenPublishingConventionsPlugin.java @@ -22,6 +22,12 @@ public class MavenPublishingConventionsPlugin implements Plugin { @Override public void execute(MavenPublishPlugin mavenPublish) { PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); + if (project.hasProperty("deploymentRepository")) { + publishing.getRepositories().maven((mavenRepository) -> { + mavenRepository.setUrl(project.property("deploymentRepository")); + mavenRepository.setName("deployment"); + }); + } publishing.getPublications().withType(MavenPublication.class) .all((mavenPublication) -> MavenPublishingConventionsPlugin.this.customizePom(mavenPublication.getPom(), project)); MavenPublishingConventionsPlugin.this.customizeJavaPlugin(project);