I have a “build.gradle” and I want to interact with the model of a plugin I’ve applied (Plugin X).
What’s the correct way to do this? I can’t do it from project space, because the model hasn’t been evaluated yet. I expect that I would need to build a RuleSource plugin in my build.gradle and apply that?
class CustomRules extends RuleSource {
@Finalize
void injectMyTask(ModelMap<Task> tasks) {
tasks.create("hello") {
doLast {
println "Hello tomato"
}
dependsOn "someTaskInPluginX" //<-- can this be typed?
}
}
}
apply plugin: CustomRules
In this case, I’m not sure about a couple of things
- Can I make any assumptions about the order
@Finalize
methods are run? Finalize in pluginX before Finalize in CustomRules? - Would adding
@Path("tasks.someTaskInPluginX")
to myInjectMyTask
method ensuresomeTaskInPluginX
is set up before?
Should PluginX be doing a better job of managing it’s RuleSource with@Mutate
and@Finalize
?