Explaination of `Gradle does not know how file was created`


(Marcin Zajączkowski) #1

Hi. I’m converting a plugin generating Wiremock stubs from µservice contracts written in Groovy DSL. I marked input directory as @InputDirectory and output as @OutputDirectory. In the task an another class is called which do the convertion/generation. A task is marked as @CacheableTask. When I call this task twice I see it is “up-to-date”. However, when I use build cache on a CI server the task is executed with the following message:

Caching disabled for task ':xxx:generateAccurest': Gradle does not know how
file 'build/production/xxx-stubs/mappings/xxx/paymentResource/shouldReturn406ForBadContentType.json' 
was created (output property 'configProperties.stubsOutputDir'). Task output caching
requires exclusive access to output paths to guarantee correctness.

What can be a reason? Why Gradle doesn’t “see” that given files were craated during a task execution?


(Stefan Wolf) #2

Hi Marcin,

the message means that some other file appeared in the output directory which was not recognized as an output of the task. The most common reason for this is that another task writes its output to the same directory. Cacheable tasks require exclusive access to their output directories. See the corresponding section in the build cache guide.

Cheers,
Stefan


(Marcin Zajączkowski) #3

Thanks for your response Stefan. I will take a closer look at it after weekend, but in the meantime one question. I upgraded the plugin from the older version that could create files in a subdirectory of a root output directory used by the current version . Can it confuse Gradle (i.e. files created in a subdirectory by older version are restored and Gradle doesn’t match it)?

I will also clear up the cache to check if the problem is reproducible.


(Stefan Wolf) #4

Hi Marcin,

I upgraded the plugin from the older version that could create files in a subdirectory of a root output directory used by the current version . Can it confuse Gradle (i.e. files created in a subdirectory by older version are restored and Gradle doesn’t match it)?

Which plugin did you upgrade? Could you give me an example what you think happened which could confuse Gradle? Note that there will be no cache hits between Gradle versions since the version of Gradle is an input to all tasks.

Cheers,
Stefan


(Marcin Zajączkowski) #5

It was an upgrade of a version of the plugin changed to the version in which I added caching and fix declaring inputs/outputs. As I did a few things I will try to reproduce the problem with cleared cache and I will come back to you with more details after weekend.


(Marcin Zajączkowski) #6

The plugin logic analysis suggested that the problem could be overlapping outputs and the script confirmed it. Two tasks hade the same configuration object appended as @Nested and some @Outputs (even if not used) caused that issue. I will rework the configuration.