File dependencies


I come from many years of experience with make. One thing that is baffling me is the use of task dependencies rather than file dependencies in Gradle. For example, if I have a C program that has these dependencies (in makefile format):

app : file1.o file2.o

file1.o : file1.c file1.h file2.h

file2.o : file2.c file2.h

So, both object files are dependent on file2.h and would be rebuilt if file2.h changed. However, if file1.h changed, only file1.o would be built.

How can I represent this in Gradle? I am mainly interested in how one can handle this in raw Gradle as opposed to using a plugin.


Blake McBride

The answer has to do with Gradle’s incremental build support. It is documented at and