Hello, we am trying to share gradle cache among di...
# caching
j
Hello, we am trying to share gradle cache among different devcontainers with vscode for our local development. We initially encountered the journal lock issue when different devcontainer mounts to the same ~/.gradle/caches folder and today our workaround is to have cache on individual devcontainer. We are using gradle version 8.13 and with gradle for java extension https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-gradle. I wonder if this is an issue on vscode extension or sharing gradle cache among different containers. Not sure if this is the right place for this enquiry but let me know if any information needed. Thanks!
v
If you want to share one cache among separate machines, you should only do so with a read-only cache. Multiple machines accessing the same read-write cache is not a good idea usually. https://docs.gradle.org/current/userguide/dependency_caching.html#sec:shared-readonly-cache
j
Thanks @Vampire. This information is helpful
👌 1
Hello @Vampire, it does help to resolve the lock issue with read-only cache. But the read-only cache cannot be updated itself but copy from the $GRADLE_HOME/caches folder in order to keep it updated.
v
Of course it cannot be updated, it is read-only, the name implies that already. 😄
The sense of the read-only cache is, that most of the things that would need to be downloaded are there already.
Why do you want to share a writable cache between multiple machines?
What is your use-case?
j
We are making use of devcontainer to help developers to spin up different java / gradle projects to ease of preparing local with different tools installation (e.g. jdk, other proprietary tools). We tried to minimize the redownloading all dependencies by mounting $HOME/.gradle/cache to individual devcontainers but encountering the lock issue.
v
Yeah, well, don't start multiple systems on the same writable cache.
j
Anyway, I think it's just the initial start up time as long as the docker image still exists. And try to ease the pain of the ramp up time redownloading dependencies in this use case.
v
try to ease the pain of the ramp up time redownloading dependencies in this use case.
That's what a read-only cache is for, isn't it?
j
It helps at the moment but I hope the cache locking can be enhanced to support such use case.
v
Quite unlikely, as you most probably cannot do proper locking across systems. But feel free to open a feature request asking for it and see what the Gradle folks say. I'm just a user like you. 🙂