Disallow actions that should not happen inside a task's configuration #27030
Labels
a:feature
A new functionality
@configuration-cache
in:configuration-model
lazy api, domain object container
in:writing-tasks
task option
re:comprehensibility
reasonable errors and warnings, clear dsl, mental overload
Current Behavior
Currently, registering a task in another task's configuration will fail with:
However, as of version 8.4, Gradle still allows the following actions to take place inside a task's configuration:
Configuration
BuildService
TransformAction
Expected Behavior
It would be great if Gradle could clarify what actions are okay to run inside a task's configuration and what actions are not, and fail the build for actions that should not be run inside a task's configuration (similar to the error for registering a task above).
Context (optional)
On one hand, performing the above actions in the task configuration has these benefits:
L8DexDesguarLibTask's desugaredDesugarLibJar
property is configured only under a certain condition, and its value is obtained through a transform, so it's easier/cleaner to register the transform where it's needed. (It's similar to a good software practice where a local variable should be declared close to where it is used).On the other hand, performing these actions in the task configuration might cause issues with configuration-on-demand, configuration cache, composite builds, etc. Gradle users/plugin authors are unlikely to be aware of these issues, which result in latent, hard-to-debug problems.
Steps to Reproduce
(See above)
Gradle version
8.4
Build scan URL (optional)
No response
Your Environment (optional)
No response
The text was updated successfully, but these errors were encountered: