From 47cbdf3d6030abec744486b158e061d0e8a638b2 Mon Sep 17 00:00:00 2001 From: Mateusz Rzeszutek Date: Fri, 21 Oct 2022 14:42:53 +0200 Subject: [PATCH] Revert removing the mavenCentral repo from the muzzle check plugin (#6937) Fixes #6932 Replaces #6933 @aaron-ai I finally understood what you meant in #6796 after seeing your PR - initially I thought you were talking about some custom extension, that's outside of this repository. I added back the maven central fallback to the muzzle check plugin: after investigating a bit, I found out that the repositories defined in `settings.dependencyResolutionManagement` are not propagated at all (no matter whether it's `afterEvaluate` or not) to the `project.repositories`, and that the gradle issue https://github.com/gradle/gradle/issues/17295 is still valid. --- ...elemetry.instrumentation.muzzle-check.gradle.kts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-check.gradle.kts b/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-check.gradle.kts index 71b6f48dca..6856d7adce 100644 --- a/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-check.gradle.kts +++ b/gradle-plugins/src/main/kotlin/io.opentelemetry.instrumentation.muzzle-check.gradle.kts @@ -172,7 +172,7 @@ if (hasRelevantTask) { } fun getProjectRepositories(project: Project): List { - return project.repositories + val projectRepositories = project.repositories .filterIsInstance() .map { RemoteRepository.Builder( @@ -181,6 +181,17 @@ fun getProjectRepositories(project: Project): List { it.url.toString()) .build() } + // dependencyResolutionManagement.repositories are not being added to project.repositories, + // they need to be queries separately + if (projectRepositories.isEmpty()) { + // Manually add mavenCentral until https://github.com/gradle/gradle/issues/17295 + // Adding mavenLocal is much more complicated but hopefully isn't required for normal usage of + // Muzzle. + return listOf(RemoteRepository.Builder( + "MavenCentral", "default", "https://repo.maven.apache.org/maven2/") + .build()) + } + return projectRepositories } fun createInstrumentationClassloader(): ClassLoader {