Closed big-guy closed 5 years ago
I toyed with this change to disallow mutation of a task other than the subject of a lazy configuration: https://github.com/gradle/gradle/commit/e6ba5472f4218c91b7cb08b239b9d85042483677
Do we want to solve it this way?
We will fix this issue with a documentation fix for 5.0 and revisit this at a later date: https://github.com/gradle/gradle/pull/6904
The problem: https://github.com/gradle/kotlin-dsl/blob/79783269fcec99f858a6ae30bbe1e699f07ffefb/samples/code-quality/build.gradle.kts#L45-L46
When configuring
jacocoTestCoverageVerification
, we also configuredcheck
. WhenjacocoTestCoverageVerification
was made lazy,check
was no longer configured to depend on it unlessjacocoTestCoverageVerification
was realized/executed.The fix was to separate the configuration steps: https://github.com/gradle/kotlin-dsl/blob/e3fcf65e8e278a36be82316f922afb15525cae9f/samples/code-quality/build.gradle.kts#L41-L48
It's perfectly valid to get the
check
task and query things from it when configuringjacocoTestCoverageVerification
, but any kind of assignment/configuration ofcheck
would cause this kind of problem and I think is hard to detect.We call this out as part of the migration guide: https://docs.gradle.org/nightly/userguide/task_configuration_avoidance.html#sec:task_configuration_avoidance_migration_guidelines
But it may not be clear what "mutate anything" means.