Hm, my challenge is more tricky. I want the inputs and outputs (based on directories) to be included in the uptodate check and I also want an additional condition to be included in the uptodate check. If any of them (inputs/outputs/custom) says that the task is outdated, the task should be run. The problem with task.onlyIf() is that it works exclusively, i.e. if it returns false, it does not matter if the inputs and outputs are ‘dirty’ or not (also, the task will be marked as skipped and not as uptodate).
If there is no API to add a custom condition that does not act exclusively in the decision whether the task is uptodate or not, I wonder if there is an API that allows me to check if the inputs and outputs of a given task are uptodate, something like boolean TaskManager.areInputsUptodate(task) (I’m making that API up for clarity). I guess Gradle must have this kind of API internally anyway to check the uptodate status of a task.
Note that using the weekday in my custom check is not my real use case, but I think it is a simple to understand example. In my real use case, I want to check the state of my database (on top of some config files declared as inputs and some generated source code declared as outputs).
Any help is appreciated!