I am trying to update/rewrite an old Gradle plugin of ours, but have stumbled across something I don’t understand. (I am using Gradle 5.6.4 and cannot upgrade to Gradle 6.x yet.) Our plugin is applied to the root project and invokes:
project.getTasksByName("doesNotExist", true);
as the first line of its afterEvaluate()
handler. The handler then continues by invoking project.getTasks().findByPath(t)
and performing Task
discovery across the entire project tree. This all works, although it is ugly.
The documentation for Project.getTasksByName()
says:
NOTE: This is an expensive operation since it requires all projects to be configured.
which I assumed was the reason why the plugin was invoking it in the first place. And so then I tried replacing it with:
project.evaluationDependsOnChildren();
because I thought this would make the plugin’s intention clearer. However, this did not work! More precisely, Gradle suddenly became unable to configure some sub-projects that were using the
org.springframework.boot
and
io.spring.dependency-management
plugins, saying (e.g.) that it hadn’t registered an id of org.springframework.boot
and that therefore it was not correctly implemented.
Revert my plugin back to using Project.findTasksByName(name, true)
and suddenly the Srping plugins can be applied successfully again.
Clearly Project.findTasksByName()
is doing more than Project.evaluationDependsOnChildren()
does. Can anyone explain what that might be, please? I have considered “evaluation” and “configuration” to be the same thing, as far as Gradle projects are concerned. Is this incorrect?
Thanks for any help here,
Cheers,
Chris