Skip to content

Commit

Permalink
Add test case to reproduce #11300
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Nov 12, 2019
1 parent 4adbee6 commit 91547cf
Showing 1 changed file with 59 additions and 0 deletions.
Expand Up @@ -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:
Expand Down

0 comments on commit 91547cf

Please sign in to comment.