I would like my configuration cache for a task to invalidate if a specific file changes.
I tried the following:
kotlinCompileTasks
is a collection of all of my kotlin compile Task
objects.
kotlinCompileTasks.all {
it.inputs.file(projectDir.resolve("build.json"))
}
build.json is a custom file that I use during configuration. If build.json changes, I want the configuration cache to be invalidated.
The code above is not working. I expect that if I edit build.json, the configuration cache would invalidate. However, it does not invalidate but instead is reused even when build.json is edited.
I think I understand why. In the docs, it says:
Build configuration inputs include:
- Init scripts, settings scripts, build scripts.
- System properties, Gradle properties, environment variables used during the configuration phase
- Configuration files accessed using value suppliers such as providers
buildSrc
build configuration inputs and source files.
And I guess setting a task input file doesn’t belong to any of the above categories. But even with the list above, I do not know how I can achieve my goal. I’m guessing I should use a “value supplier”? But, I do not know how.