:wave: Hey folks! Quick question, I'm banking on s...
# plugin-development
j
👋 Hey folks! Quick question, I'm banking on someone hopefully knowing the answer. Can dependency substitution rules stack? For example, if I have this (pseudo-code):
Copy code
configurations.compileClasspath.dependencySubstitutions {
    substitute module('org.example:examplelib') using variant(module('org.example:examplelib')) {
        attributes { attribute(MyAttribute.ATTR_1, true) }
    }

    substitute module('org.example:examplelib') using variant(module('org.example:examplelib')) {
        attributes { attribute(MyAttribute.ATTR_2, true) }
    }
}
Would the resolver try to select the dependency in a way where both ATTR_1 and ATTR_2 are true? (I can obviously test it myself but am just checking to see if anyone knew the answer to this before I did some experiments)
To answer my own question, I think the answer is "yes", albeit with some caveats. It looks like what adding the substitution does is add variant selectors, not to be confused with simply replacing a module with the strict variant specified. And from what I can tell reading internals, they do stack. Although it's brittle. I'll consider it something to avoid, as it's mostly a temporary solution for something else I'm working on.