Gradle tasks from root project takes 30 minutes

Something is seriously broken with gradle tasks. If I run it from my root project it takes up to 30 minutes. gradle clean build only takes 10 minutes if run with --parallel and 15-20 minutes if run sequentially. If I do an strace of the process I just see it doing tons of stat/lstat calls on files/directories in my source / output directory. It seems like it’s scanning all the source / target directories excessively.

Any idea why this is happening? If we’re doing something wrong it’s completely non-obvious what.