Closed musketyr closed 3 years ago
This may be a tricky thing to fix given that Gradle does not offer a proper way to handle multiple plugins contributing tasks that may override one another. We have access to TaskContainer.register()
and TaskContainer.matching()
which are lazy. TaskContainer.findByName()
is eager.
What we need is a way to register a task if it does not exist yet, either at the point of checking or at the time the task graph is about to be resolved. Sadly there's no way to make it happen, cleanly.
Ok, so what about the other option? Do not add the task when it is disabled?
Yes, that could work. As a matter of fact that was the original behavior many releases ago but then some tasks would fail as they could not find their requirements/dependencies, such as createGuide
when an aggregate task was unavailable. I deiced then to still register tasks but disable them by default.
What about this, keep the current behavior but add a new flag that controls whether disabled tasks really get added or not. That way you have 3 options at hand:
Sounds good!
I've decided to not add yet anther flag and go back to the previous behavior of skipping task registration in the plugin is disabled. It will work in the following way:
sourcesJar
)mainCodenarc
because this task will always be registered by a 3rd party plugin).
For example both SourceJarPlugin and GrailsPluginGradlePlugin both creates
sourceJar
tasks. IfGrailsPluginGradlePlugin
is applied in a child project then the build fails to evaluate. Would be nice if the tasks are added only if the task is not already present. Other option would be not to add the tasks when it is disabled as this information should be known at the time of adding.