ModelRegistry tasks are not available to plugins via getByName in 1.9

In 1.9, it appears that the TaskModelRealizingConfigurationAction runs after BuildScriptProcessor. This consequently means that if I reference a task managed by the ModelRegistry in a plugin using tasks.getByName, my build will fail when the BuildScriptProcessor runs my plugin. My canonical example are the generateDescriptorFileFor%sPublication tasks. I used to reference them immediately via tasks.getByName in my plugin, but in 1.9 they’re not available yet. I’m not saying that anything has to change, just mentioning it as a regression, since these documented tasks were available immediate after applying the plugin before.

A work around is to use the DomainObjectCollection matching and all methods, e.g.

project.tasks.matching { it.name == 'generateDescriptorFileForJavaPublication'}.all {
DefaultTask generateDescriptorTask ->
  // Do something with generate task
}

Hi Justin,

We are in a bit of limbo with the model registry. Unfortunately it leaked through well undercooked for 1.9.

We’ll look to resolve this in 1.11 somehow, probably just docs as you suggest.