How to enforce cachability of custom gradle tasks through an abstract Gradle Task

plugins

(SubratMohapatra) #1

Since the @CacheableTask is not declared as @Inherited , is there some possibility to declare an abstract Task and still enforce the Task extending this super Class as @CacheableTask?


(Stefan Wolf) #2

So what you want to achieve is that all subclasses of your task are cacheable? That is currently not possible via an annotation. You could use outputs.cacheIf { true } in the constructor of the base class.

Note that this is very dangerous, since you don’t have any guarantee that subclasses declare the right inputs and outputs to make them safely cacheable.