Declaring capabilities for external modules. question

i tried" Example 2. A build file with an implicit conflict of logging frameworks" in https://docs.gradle.org/current/userguide/component_capabilities.html.

but cannot resolve symbol ‘id’, ‘allVariants’, ‘withCapabilities’

how can i solve this problem?

@CompileStatic
class AsmCapability implements ComponentMetadataRule {
void execute(ComponentMetadataContext context) {
context.details.with {
if (id.group == “asm” && id.name == “asm”) {
allVariants {
it.withCapabilities {
// Declare that ASM provides the org.ow2.asm:asm capability, but with an older version
it.addCapability(“org.ow2.asm”, “asm”, id.version)
}
}
}
}
}
}

Hi @imjjmoa,

This should work. Which Gradle version are you using?
What do you get if you remove @CompileStatic? You can also move the rule class into a separate Groovy file in buildSrc. Maybe that reveals the problem.