From 30bc2634d78c5b905f3309f66c0db09e45459711 Mon Sep 17 00:00:00 2001 From: Eric Haag Date: Mon, 24 Jul 2023 14:00:33 -0500 Subject: [PATCH] Optimize configuration of project repositories This change applies repository content filtering to configured repositories, reducing the time spent during dependency resolution. This fixes an issue where requests for 'org.opensaml', 'net.shibboleth.utilities' and 'net.minidev' dependencies were being made in the Spring releases repositories, resulting in many failed requests during dependency resolution and increased resolution times. Closes gh-13582 --- .../convention/RepositoryConventionPlugin.groovy | 15 +++++++++++---- .../RepositoryConventionPluginTests.java | 14 +++++++------- config/spring-security-config.gradle | 4 ---- docs/spring-security-docs.gradle | 8 +------- 4 files changed, 19 insertions(+), 22 deletions(-) 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 407163d82a..860c9bb642 100644 --- a/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy +++ b/buildSrc/src/main/groovy/io/spring/gradle/convention/RepositoryConventionPlugin.groovy @@ -34,6 +34,14 @@ class RepositoryConventionPlugin implements Plugin { if (forceMavenRepositories?.contains('local')) { mavenLocal() } + maven { + name = 'shibboleth' + url = 'https://build.shibboleth.net/nexus/content/repositories/releases/' + content { + includeGroup('org.opensaml') + includeGroup('net.shibboleth.utilities') + } + } mavenCentral() if (isSnapshot) { maven { @@ -67,12 +75,11 @@ class RepositoryConventionPlugin implements Plugin { password project.artifactoryPassword } } + content { + excludeGroup('net.minidev') + } url = 'https://repo.spring.io/release/' } - maven { - name = 'shibboleth' - url = 'https://build.shibboleth.net/nexus/content/repositories/releases/' - } } } diff --git a/buildSrc/src/test/java/io/spring/gradle/convention/RepositoryConventionPluginTests.java b/buildSrc/src/test/java/io/spring/gradle/convention/RepositoryConventionPluginTests.java index f1048dbbab..282bfe4f0e 100644 --- a/buildSrc/src/test/java/io/spring/gradle/convention/RepositoryConventionPluginTests.java +++ b/buildSrc/src/test/java/io/spring/gradle/convention/RepositoryConventionPluginTests.java @@ -125,27 +125,27 @@ public class RepositoryConventionPluginTests { private void assertSnapshotRepository(RepositoryHandler repositories) { assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(5); - assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) - .isEqualTo("https://repo.maven.apache.org/maven2/"); assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) - .isEqualTo("https://repo.spring.io/snapshot/"); + .isEqualTo("https://repo.maven.apache.org/maven2/"); assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) + .isEqualTo("https://repo.spring.io/snapshot/"); + assertThat(((MavenArtifactRepository) repositories.get(3)).getUrl().toString()) .isEqualTo("https://repo.spring.io/milestone/"); } private void assertMilestoneRepository(RepositoryHandler repositories) { assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(4); - assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) - .isEqualTo("https://repo.maven.apache.org/maven2/"); assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) + .isEqualTo("https://repo.maven.apache.org/maven2/"); + assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) .isEqualTo("https://repo.spring.io/milestone/"); } private void assertReleaseRepository(RepositoryHandler repositories) { assertThat(repositories).extracting(ArtifactRepository::getName).hasSize(3); - assertThat(((MavenArtifactRepository) repositories.get(0)).getUrl().toString()) - .isEqualTo("https://repo.maven.apache.org/maven2/"); assertThat(((MavenArtifactRepository) repositories.get(1)).getUrl().toString()) + .isEqualTo("https://repo.maven.apache.org/maven2/"); + assertThat(((MavenArtifactRepository) repositories.get(2)).getUrl().toString()) .isEqualTo("https://repo.spring.io/release/"); } diff --git a/config/spring-security-config.gradle b/config/spring-security-config.gradle index 5c634a1abb..365f08753e 100644 --- a/config/spring-security-config.gradle +++ b/config/spring-security-config.gradle @@ -4,10 +4,6 @@ apply plugin: 'io.spring.convention.spring-module' apply plugin: 'trang' apply plugin: 'kotlin' -repositories { - maven { url "https://build.shibboleth.net/nexus/content/repositories/releases/" } -} - dependencies { management platform(project(":spring-security-dependencies")) // NB: Don't add other compile time dependencies to the config module as this breaks tooling diff --git a/docs/spring-security-docs.gradle b/docs/spring-security-docs.gradle index 4497c2e2b2..a5ca6fa8cf 100644 --- a/docs/spring-security-docs.gradle +++ b/docs/spring-security-docs.gradle @@ -1,6 +1,7 @@ plugins { id 'org.antora' version '1.0.0' id 'io.spring.antora.generate-antora-yml' version '0.0.1' + id 'io.spring.convention.repository' } apply plugin: 'io.spring.convention.docs' @@ -59,10 +60,3 @@ def resolvedVersions(Configuration configuration) { .resolvedArtifacts .collectEntries { [(it.name + '-version'): it.moduleVersion.id.version] } } - -repositories { - mavenCentral() - maven { url 'https://repo.spring.io/release' } - maven { url 'https://repo.spring.io/milestone' } - maven { url 'https://repo.spring.io/snapshot' } -}