However, the task is always considered UP-TO-DATE even when I make changes to my Generator.java or delete some files in the ouputDir. The way I read it in the documentation was that gradle maintains a hash and if the hash changes because of the changes in the inputs/outputs it will rerun the task. What am I doing wrong here?
I figured out what I was doing wrong. The piece of code was placed in the build.gradle of the app folder in the android project. buildSrc was a subfolder of the root project. So inpFile was never found. A file.exists check revealed this blunder. According to the documentation:
A task with only outputs defined will be considered up-to-date if those outputs are unchanged since the previous build.
This was why changes to the input file was never registered.
Although, I still have a question. According to the documentation:
Note that if a task has an output directory specified, any files added to that directory since the last time it was executed are ignored and will NOT cause the task to be out of date
I deleted a file from the output directory. This should have made the task out-of-date but it didn’t. Is this expected behavior? Am I reading the documentation wrong?
PS: I did check if the output directory exists and it does.