Be a nice freedesktop citizen, move the ~/.gradle to the appropriate location in Linux

According to the XDG specification [1], there is a better way to store the user specific data of an application by dumping in new hidden folder in ~/. More information about it can be found [2]

The specification defines places to store the data so that the user profile can be updated and moved properly while reducing some weird bugs. Those places would be ~/.local/gradle or ~/.cache/gradle and other (depending on the data stored)

[1]: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html [2]: https://ploum.net/207-modify-your-application-to-use-xdg-folders/

1 Like

Gradle user home directory location is configurable. You can configure it via either one of the following:

  • 'GRADLE_USER_HOME ’ env variable * ‘gradle.user.home’ system proprty * ‘----gradle-user-home’ switch on the command line

Saying that any individual user can configure his/her environment to be consistent with XDG is likely beside the point.

Just to be clear, I’m not necessarily endorsing the XDG specification, although from a quick review it seems like a reasonable idea.

If the OP feels strongly enough about this, they should file an issue stating that the default should be consistent with the XDG specification, instead of leaving it up to individual users. If you can’t depend on most users using this configuration, common tools that expect this convention won’t be that useful. You should provide statements to that effect to make a convincing argument in the issue.

@Marcin

Thanks for your answer but this is a workaround.

The user shouldn’t have to do extraneous configuration to have gradle to conform to the platform specifications.

The XDG specs are really how things are working now on Linux desktops and are rules that applications have to follow not to mess with user profiles.

My first message was supposed to have links that I’m reposting here for clarity. http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html https://ploum.net/207-modify-your-application-to-use-xdg-folders/

I too am interested in this being implemented. I often have to mess with options and environment variables to throw away all kinds of trash from my home directory root, but that applies only to dead or no longer actively developed projects. This is also really easy to implement - just set default location of GRADLE_USER_HOME to value of XDG_CACHE_HOME for Linux builds.

Pointing ‘GRADLE_USER_HOME’ to ‘XDG_CACHE_HOME’ creates the impression that everything is temporary.

There is a slight complication in this. Although most files in ‘~/.gradle’ can be considered temporary, this is not the case with ‘gradle.properties’. I have in more than one occasion accidentaly deleted my custom settings by wiping the ‘~/.gradle’ folder.

It might be better for Gradle to provide an additional environment variable to look for gradle.properties, so that both can be set for a freedekstop environment.

Anyhow after all of this I have always been under the impression that Freedesktop standard was for apps runnign in a X11/Xorg (or post-Xorg) environment. Gradle is essentialy a command-line tool, so I wonder if anything discussed prior to this, is of significance.

@schalk

It is important because while gradle can be ran in a server it can also be ran on a desktop (windows, macosx, linux) and i feel that’s important that it plays nice also in those environment. Which it does in most of the time.

There’s only a tiny fix needed to support linux desktops swimmingly.

Besides this remark, I agree with your point: gradle configuration shouldn’t be in ~/.cache

1 Like