@@ -265,7 +265,7 @@ class SmokeTestAppEndToEndTest {
265265 }
266266
267267 @Test
268- fun `local proxy property prepends Maven proxy repositories exactly once ` () {
268+ fun `Maven proxy replaces Maven Central in nested repositories ` () {
269269 writeOuterSettings()
270270 val proxyRepository = projectDir.resolve(" proxy-maven-repo" ).toFile()
271271 val projectRepository = projectDir.resolve(" project-maven-repo" ).toFile()
@@ -279,7 +279,19 @@ class SmokeTestAppEndToEndTest {
279279 sysProperty = " resolved.repositories.path" ,
280280 ),
281281 )
282- writeInnerSettings()
282+ writeInnerSettings(
283+ """
284+ gradle.settingsEvaluated {
285+ val outputDir = java.io.File(providers.gradleProperty("appBuildDir").get())
286+ outputDir.mkdirs()
287+ outputDir.resolve("plugin-repositories.txt").writeText(
288+ pluginManagement.repositories
289+ .withType(org.gradle.api.artifacts.repositories.MavenArtifactRepository::class.java)
290+ .joinToString(System.lineSeparator()) { "repository=" + it.url }
291+ )
292+ }
293+ """ .trimIndent(),
294+ )
283295 writeInnerBuild(
284296 """
285297 repositories {
@@ -301,8 +313,12 @@ class SmokeTestAppEndToEndTest {
301313 val artifacts = configurations.compileClasspath.get()
302314 .sortedBy { it.name }
303315 .map { it.name + "=" + it.readText() }
316+ val repositoryUrls = repositories
317+ .withType(org.gradle.api.artifacts.repositories.MavenArtifactRepository::class.java)
318+ .map { "repository=" + it.url }
304319 resolved.get().asFile.writeText(
305- (listOf("init-script-count=" + gradle.startParameter.initScripts.size) + artifacts)
320+ (listOf("init-script-count=" + gradle.startParameter.initScripts.size) +
321+ repositoryUrls + artifacts)
306322 .joinToString(System.lineSeparator())
307323 )
308324 }
@@ -319,11 +335,25 @@ class SmokeTestAppEndToEndTest {
319335 assertThat(result.task(" :resolveRepositories" )?.outcome).isEqualTo(TaskOutcome .SUCCESS )
320336 val resolvedFile = applicationOutput(" resolved-repositories.txt" )
321337 assertThat(resolvedFile).exists()
322- assertThat(resolvedFile.readLines()).containsExactly(
338+ val resolvedLines = resolvedFile.readLines()
339+ assertThat(resolvedLines).contains(
323340 " init-script-count=1" ,
341+ " repository=${proxyRepository.toURI()} " ,
324342 " project-only-1.0.jar=project-only" ,
325343 " shared-1.0.jar=proxy" ,
326344 )
345+ assertThat(resolvedLines).doesNotContain(
346+ " repository=https://repo.maven.apache.org/maven2/" ,
347+ )
348+ val pluginRepositoriesFile = applicationOutput(" plugin-repositories.txt" )
349+ assertThat(pluginRepositoriesFile).exists()
350+ val pluginRepositoryLines = pluginRepositoriesFile.readLines()
351+ assertThat(pluginRepositoryLines).contains(
352+ " repository=${proxyRepository.toURI()} " ,
353+ )
354+ assertThat(pluginRepositoryLines).doesNotContain(
355+ " repository=https://repo.maven.apache.org/maven2/" ,
356+ )
327357 }
328358
329359 @Test
@@ -649,10 +679,11 @@ class SmokeTestAppEndToEndTest {
649679 " fake-mvnw"
650680 }
651681
652- private fun writeInnerSettings () {
682+ private fun writeInnerSettings (additionalContent : String = "" ) {
653683 File (applicationDir, " settings.gradle.kts" ).writeText(
654684 """
655685 rootProject.name = "smoke-test-app-fixture-application"
686+ $additionalContent
656687 """ .trimIndent(),
657688 )
658689 }
0 commit comments