From 91547cf77d4fd6839795076a26a6b95c6ef26478 Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Tue, 12 Nov 2019 16:27:27 +0100 Subject: [PATCH] Add test case to reproduce #11300 --- .../CapabilitiesRulesIntegrationTest.groovy | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/subprojects/dependency-management/src/integTest/groovy/org/gradle/integtests/resolve/capabilities/CapabilitiesRulesIntegrationTest.groovy b/subprojects/dependency-management/src/integTest/groovy/org/gradle/integtests/resolve/capabilities/CapabilitiesRulesIntegrationTest.groovy index 3cf0750f5b2e..2695b10ebc49 100644 --- a/subprojects/dependency-management/src/integTest/groovy/org/gradle/integtests/resolve/capabilities/CapabilitiesRulesIntegrationTest.groovy +++ b/subprojects/dependency-management/src/integTest/groovy/org/gradle/integtests/resolve/capabilities/CapabilitiesRulesIntegrationTest.groovy @@ -77,6 +77,65 @@ class CapabilitiesRulesIntegrationTest extends AbstractModuleDependencyResolveTe Cannot select module with conflict on capability 'cglib:cglib:3.2.5' also provided by [cglib:cglib-nodep:3.2.5($variant)]""") } + def "implicit capability conflict is detected if implicit capability is discovered late"() { + given: + repository { + 'cglib:cglib:3.2.5'() + 'cglib:cglib-nodep:3.2.5'() + 'org:lib:1.0' { + dependsOn 'cglib:cglib:3.2.5' + } + } + + buildFile << """ + class CapabilityRule implements ComponentMetadataRule { + + @Override + void execute(ComponentMetadataContext context) { + def details = context.details + details.allVariants { + withCapabilities { + addCapability('cglib', 'cglib', details.id.version) + } + } + } + } + + dependencies { + conf "cglib:cglib-nodep:3.2.5" + conf "org:lib:1.0" + + components { + withModule('cglib:cglib-nodep', CapabilityRule) + } + } + """ + + when: + repositoryInteractions { + 'cglib:cglib-nodep:3.2.5' { + expectGetMetadata() + } + 'cglib:cglib:3.2.5' { + expectGetMetadata() + } + 'org:lib:1.0' { + expectGetMetadata() + } + } + fails ':checkDeps' + + then: + def variant = 'runtime' + if (!isGradleMetadataPublished() && useIvy()) { + variant = 'default' + } + failure.assertHasCause("""Module 'cglib:cglib-nodep' has been rejected: + Cannot select module with conflict on capability 'cglib:cglib:3.2.5' also provided by [cglib:cglib:3.2.5($variant)]""") + failure.assertHasCause("""Module 'cglib:cglib' has been rejected: + Cannot select module with conflict on capability 'cglib:cglib:3.2.5' also provided by [cglib:cglib-nodep:3.2.5($variant)]""") + } + @Unroll def "can detect conflict with capability in different versions (#rule)"() { given: