Any Drawbacks of Sharing the Gradle User Home with

2019-06-07 07:55发布

问题:

Question

In a Nutshell

Are there any drawbacks of sharing the Gradle user home amongst multiple developers on the same filesystem?

In More Detail

Our goal is to save disk space with the local Gradle cache. The Gradle user guide suggests that the cache is safe for concurrent access. There doesn’t currently seem to be any way to configure the cache location independently from the Gradle user home, so essentially the question boils down to sharing the Gradle user home (defaults to ~/.gradle/). In a quick test we could verify that multiple concurrent processes of the same user do indeed work flawlessly with a single Gradle user home.

But could there be any problems with multiple users? I could imagine that permission issues might become a problem. Does anyone have any experience with such a setup? Are there any files in the Gradle user home which shouldn’t be shared?

It’s clear that certain user-specific configurations wouldn’t be possible anymore with a shared user home (like personalized init scripts or gradle.properties). Do you perhaps have any better suggestion for saving disk space with the local Gradle cache? Such a suggestion could be to somehow automatically prune the cache of each user as asked in this SO question.

Background

We use Gradle for working with somewhat bigger binary files (currently ~500M each and growing). This includes building them from other big binary artifacts as input dependencies. We store our build artifacts in Artifactory; uploading and downloading goes pretty smoothly. However, since we have about 50 developers who are mixing and matching many files every week, the local Gradle cache of each developer grows rather quickly. As all developers work on the same filesystem, we were thinking about having a shared Gradle cache for all developers to save disk space.

回答1:

I have just found this comment by Gradle developer Stefan Oehme wrt. sharing the Gradle user home:

Gradle processes will hold locks if they are uncontended (to gain performance). Contention is announced through inter-process communication, which does not work when the processes are isolated in Docker containers.

And more clearly he states in a follow-up comment (highlighting by me):

There might be other issues that we haven't yet discovered though, since sharing a user home between machines is not a use case we have designed for.

In other words: sharing a Gradle user home or even just the cache part of it across different machines is currently not officially supported by Gradle.



回答2:

As you reference ~/.gradle/, I guess you are on a *nix machine?
Then simply make the cache folder a symlink to some shared folder and you will be fine. Cache will be shared and each dev still has his own Gradle user home.



标签: gradle share