I am writing a gradle task, which will tell whethe...
# caching
s
I am writing a gradle task, which will tell whether the task is cacheble or not and if the task is pulled from cache already, the language is groovy, I have used the cacheIf method, but it seems to be not working. Can someone guide me on this on how to do this and get the required data of cache at task level
v
Can you elaborate a bit more what you are trying and what the use-case is? I for example did not understand what you want to do exactly. Do you want to write a task that reports on other tasks? Or do you mean it should determine about itself? What would you do with that information? ... The
cacheIf
is just a dynamic way to define whether a task's outputs should be cached or not.
s
I want to get the build data at the task level, essentially, to check whether the task is cacheable or not, and whether the task that is being run is pulled from cache or not since we have a lot of modules that run once a gradle build is invocated, I want that data to be updated so that we can track the status of our caches
v
If you want to track status of caches, register an
OperationCompletionListener
that can then get whether a task was run or served from cache etc. Whether it is cacheable up-front is probably hard to determine, as it is a combination of class annotation,
cacheIf
actions, ...