Use Gradle remote cache with DirectoryBuildCache

Hi,

Does there exist a way to use remote cache with DirectoryBuildCache? I tried to use it and encouraged the following problems, DirectoryBuildCache implementation requires cache directory to be writable and puts lock on it for non CI build (with isPush disabled).

Thanks,
Denis.

Hi,

I am not sure what you want to achieve. What does your configuration look like for configuring the remote cache?

The DirectoryBuildCache is meant as a local cache which is shared between build outputs on the same machine (or in the same container). If you want to share build outputs between different machines (or containers) please use an actual remote cache like the (free) build cache node.

Cheers,
Stefan

Hi Stefan,
I wanted to try DirectoryBuildCache as remote cache, I wasn’t able to find any information that restricts such use case, so I tried it.
Configuration was:

val isCiServer = System.getenv().containsKey(“CI”)

buildCache {
local {
isEnabled = !isCiServer
}
remote {
directory = File(buildCacheLocation, “build-cache”)
isPush = isCiServer
}
}

Now I am using build cache node.

Thanks,
Denis.

Hi Denis,

so what you want is a read-only, shareable version of the DirectoryBuildCache? We don’t support this, yet, since we also track access of the entries in the cache, so it can be cleaned up. What happens if you make the file system readable? Are the locks too exclusive to allow parallel usage of the cache?

Cheers,
Stefan

Hi Stefan,

Yes, this is the use case. When file system is readonly I get the following error:

Could not create service of type BuildCacheController using BuildCacheServices.createBuildCacheController().

Cache directory path_to_directory must be writable

When I provide write permissions to all the users, if first user puts lock on cache directory, the second one don’t use the cache.

Thanks,
Denis.

We currently don’t support your use-case with the directory build cache.
It would also great to detail your use-case better, so maybe the Gradle team can provide something out of the box for you. IIUC, you want to share a pre-populated version of a build cache between different Gradle processes on the same machine.

  • how do you populate the build cache?
  • what are the different Gradle processes doing on the machine?
  • what is the bigger use-case you want to solve?

Cheers,
Stefan

Hi Stefan,

The use-case is sharing pre-populated cache between different machines using shared nfs folder.
Which is updated only by CI.
The initial idea was to try the cache without using the server (it should be simpler at least for evaluation), because it does not work out of the box we moved to cache node.

Thanks,
Denis.

Hi Denis,

thank you for the insights. I think we won’t be supporting sharing the cache via NFS in the mid-term. The solution to use the cache node is the best right now.

Cheers,
Stefan