Is there a way to tell gradle to not use “.gradle” within the (root) project folder?

When gradle runs, it relies on creating a .gradle folder within the project root directory. gradle puts all sorts of information in there, for example its “file cache”.

The user guide mentions that the gradle user home location can be changed by using the $GRADLE_USER_HOME env variable. Now I am wondering if there is a way to do the same for the folder that gradle needs/wants in the project root?


Why? We build multiple different “products” out of the same source code, so our legacy backend verification build simply did call our own build tool in parallel on the same source folder. We changed the java build to gradle, but it turns out: multiple gradle daemons using the same “shared” project-root/.gradle simply doesn’t work reliably, leading to well known Timeout waiting to lock file hash cache failures.