Find out which tasks generates a file

How do I print the name of the task that generated a particular file in the build directory of my project?

I don’t know if there is a way to do that, but you can have a good guess by which directory contains the file in the build directory. By default, each task has its own temp directory which will be like this: build/tmp/<task name>, where “task name” is the name of the task such as “compileJava”. Other than that, there may be some educated guessing involved.