Browse Source

Use spring.mavenRepositories in buildSrc for all build types

Refine `buildSrc` so that `spring.mavenRepositories()` are considered
for all build types (not just milestones and snapshots). We now pass
"springFrameworkVersion" to `SpringRepositorySupport.groovy` so that
repo.spring.io doesn't get added for OSS builds using release artifacts.

Closes gh-46823
pull/48297/head
Phillip Webb 1 month ago
parent
commit
018fc57d64
  1. 18
      buildSrc/SpringRepositorySupport.groovy
  2. 5
      buildSrc/build.gradle

18
buildSrc/SpringRepositorySupport.groovy

@ -87,8 +87,8 @@ class SpringRepositoriesExtension {
addRepositories { } addRepositories { }
} }
def mavenRepositories(condition) { def mavenRepositoriesFor(version) {
if (condition) addRepositories { } addRepositories(version) { }
} }
def mavenRepositoriesExcludingBootGroup() { def mavenRepositoriesExcludingBootGroup() {
@ -100,12 +100,16 @@ class SpringRepositoriesExtension {
} }
private void addRepositories(action) { private void addRepositories(action) {
addCommercialRepository("release", false, "/spring-enterprise-maven-prod-local", action) addRepositories(this.version, action)
if (this.version.contains("-")) { }
private void addRepositories(version, action) {
addCommercialRepositoryIfNecessary("release", false, "/spring-enterprise-maven-prod-local", action)
if (version.contains("-")) {
addOssRepository("milestone", false, "/milestone", action) addOssRepository("milestone", false, "/milestone", action)
} }
if (this.version.endsWith("-SNAPSHOT")) { if (version.endsWith("-SNAPSHOT")) {
addCommercialRepository("snapshot", true, "/spring-enterprise-maven-dev-local", action) addCommercialRepositoryIfNecessary("snapshot", true, "/spring-enterprise-maven-dev-local", action)
addOssRepository("snapshot", true, "/snapshot", action) addOssRepository("snapshot", true, "/snapshot", action)
} }
} }
@ -116,7 +120,7 @@ class SpringRepositoriesExtension {
addRepository(name, snapshot, url, action) addRepository(name, snapshot, url, action)
} }
private void addCommercialRepository(id, snapshot, path, action) { private void addCommercialRepositoryIfNecessary(id, snapshot, path, action) {
if (!"commercial".equalsIgnoreCase(this.buildType)) return if (!"commercial".equalsIgnoreCase(this.buildType)) return
def name = "spring-commercial-" + id def name = "spring-commercial-" + id
def url = fromEnv("COMMERCIAL_%SREPO_URL", id, "https://usw1.packages.broadcom.com" + path) def url = fromEnv("COMMERCIAL_%SREPO_URL", id, "https://usw1.packages.broadcom.com" + path)

5
buildSrc/build.gradle

@ -23,6 +23,7 @@ plugins {
repositories { repositories {
mavenCentral() mavenCentral()
spring.mavenRepositoriesFor("${springFrameworkVersion}")
gradlePluginPortal() gradlePluginPortal()
} }
@ -31,10 +32,6 @@ java {
targetCompatibility = 17 targetCompatibility = 17
} }
repositories {
spring.mavenRepositories("${springFrameworkVersion}".contains("-"))
}
checkstyle { checkstyle {
toolVersion = "${checkstyleToolVersion}" toolVersion = "${checkstyleToolVersion}"
} }

Loading…
Cancel
Save