Closed mkobit closed 5 years ago
That is expected behaviour: the implementation of the task and its actions are always an input to the task.
For the Groovy version the same should happen - so the task should be out-of-date when you change the build script. I don't quite understand why it is not the case.
The implementation of the task action is bound to the action's classpath - since if the classpath changes the behaviour of the action will change. Gradle's up-to-date checks and build cache key calculation take the implementation of the task and its actions into account.
See the documentation in the build cache guide and the user guide.
For the Groovy version the same should happen - so the task should be out-of-date when you change the build script. I don't quite understand why it is not the case.
Do I understand it correctly, that the issue for this issue is tracked in #7923? 🤔
Yes, the actual issue is tracked in https://github.com/gradle/gradle/issues/7923. The problem is that the Groovy task is not out of date, everything is working well for Kotlin.
Thanks @wolfs , the Groovy not behaving the same is what threw me. It would definitely be useful if ad-hoc tasks were able to be up to date, but I can understand why they are not. It definitely makes the runtime input registration API a bit more problematic and requires more use of buildSrc
to define either custom a tasks or Action
implementations to be used instead.
Editing a build script causes ad-hoc tasks with inputs and outputs described to be out of date because the actions change (presumably classpath?).
Expected Behavior
Ad-hoc tasks should be
UP-TO-DATE
when the build script changes but the inputs/outputs do not.Current Behavior
Tasks are out of date, and build cache will not function as expected when the build script changes.
Context
Iterating on a build script causes all the tasks before to be out of date when they should be. Leads to a bunch of work that should be unnecessary.
Steps to Reproduce (for bugs)
Kotlin:
build.gradle.kts
Run
./gradlew kotlinTask --info
Run
./gradlew kotlinTask --info
again, see it isUP-TO-DATE
Add some other code to build script that does not modify the build script. For example, change th ebuild script to:
Run
./gradlew kotlinTask --info
Groovy
The same execution strategy in Groovy will result in the task being
UP-TO-DATE
.build.gradle
Run
./gradlew groovyTask --info
Run
./gradlew groovyTask --info
again, see it isUP-TO-DATE
Add some other code to build script that does not modify the build script. For example, change th ebuild script to:
Run
./gradlew groovyTask --info
, see it isUP-TO-DATE
Your Environment
gradle --version