gradle / kotlin-dsl-samples

Samples builds using the Gradle Kotlin DSL
https://gradle.org/kotlin/
Other
3.71k stars 434 forks source link

Kotlin ad-hoc tasks should be up-to-date when script changes but inputs and outputs do not #1271

Closed mkobit closed 5 years ago

mkobit commented 5 years ago

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:

Groovy

The same execution strategy in Groovy will result in the task being UP-TO-DATE.

Your Environment

wolfs commented 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.

StefMa commented 5 years ago

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? 🤔

wolfs commented 5 years ago

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.

mkobit commented 5 years ago

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.