How to add a AttributeCompatibilityRule from within custom plugin

Hey guys,

i would like to use the variant-aware-sharing feature within my plugin. I have to add a custom AttributeCompatibilityRule.

Can somebody share an example which ilustrates how a custom AttributeCompatibilityRule can be added in Java? I found only a DSL example:

dependencies {
    attributesSchema {
        attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE) {
            compatibilityRules.add(InstrumentedJarsRule)
        }
    }
}

Thanks

Hi @kKdH,

You can take some inspiration from the Gradle’s JavaEcosystemSupport code:

Awesome! That is what I was looking for.

1 Like