I have a custom gradle task with one input that can accept a file or a directory. I have logic in there that checks the File object to see if it’s a file or directory, and does different processing depending on the answer.
I have issues with using Task Inputs for this. If I define it as @InputFile, and the File object passed is a directory, then the task is always up-to-date. If I define it as an @InputDirectory, and the File object passed is a file, it errors.
This is the error I get when I pass a File object that is a literal file (not a directory) to a Task Input defined as @InputDirectory:
* What went wrong: A problem was found with the configuration of task ':customTask'. > File '/path/to/file' specified for property 'theFile' is not a file.
Is this simply not supported? If not… I suppose I could define two optional task inputs… one that’s a file and one that’s a directory. But the two arguments are mutually-exclusive, and that just feels wrong.