Different behavior between custom and default project cache dir in composite builds

Suppose I have a composite build of 2 projects: the main project and an included build (project included).

When I run ./gradlew help, Gradle produces 2 project-specific cache directories: .gradle and included/.gradle. However, when I run ./gradlew help --project-cache-dir SOME_DIR, Gradle produces only 1 cache directory.

The documentation says:

--project-cache-dir

Specifies the project-specific cache directory. Default value is .gradle in the root project directory.

I expect ./gradlew help and ./gradlew help --project-cache-dir .gradle would behave the same. However, the latter produces .gradle directory, but not included/.gradle. Is this expected or is this a bug?


I also experiment with property org.gradle.projectcachedir in gradle.properties with different values between the main project and included. It seems only the property for the main project takes effect, the property in the included project is ignored.

I’d guess a mixture of both.
Actually, it is more “build-specific” than “project-specific”, I’d say here “project” means a build not what a project usually means in Gradle context.
.gradle in the root project directory” matches what it says, as both of the builds participating in the composite build each have a root project, and by using that option you overwrite both of these default values to the same directory.

What I’m not sure about is, whether it will work properly.
I mean to remember that there can be problems if you configure the same cache directory for several builds.
But I might also be wrong and it was just with the build directory. :man_shrugging: