since Gradle cannot express an exclusion in a plat...
# community-support
g
since Gradle cannot express an exclusion in a platform, I'd like to embed that logic in a plugin, applied at consumers, that check if a specific dependency is present, and if yes, proceed by adding an exclusion on a specific transitive dependency would something like this suffice/work as intended? (that is, will this be evaluated after the
dependencies { }
block has been evaluated?)
Copy code
configurations.all {
    if (dependencies.find { it.group = .. && it.artifact == .. } != null)
         exclude("group", "artifact")
e
that doesn't seem like a good idea. depends on order of evaluation
why not use a component metadata rule to edit just that dependency's dependencies
g
as far as I got it, I can define the rule in a third plugin, but the user has to be aware how to apply it and do it, am I right? Like here
Copy code
components {
        withModule<TargetJvmVersionRule>("commons-io:commons-io") {
            params(7)
        }
        withModule<TargetJvmVersionRule>("commons-collections:commons-collections") {
            params(8)
        }
    }
e
your plugin could set it up
g
ok, so how it check if the dependency is present and then apply on it the rule?
e
it doesn't matter if the dependency is present or not, you can just always add a rule which only mutates the one thing you want to
g
I need to still clarify with the Scijava pom author(s) if the dependency presence or not is a strict requirement or not for the exclusion
your plugin could set it up
ah, I got what you meant just now ok, then, thanks!