The first time you trigger a gradle task using gradle wrapper, it will create a .gradle folder in which a gradle distribution gets unzipped. Is there a way to change the location of that .gradle folder?
Setting the GRADLE_USER_HOME environment variable is not what I'm looking for. When you set GRADLE_USER_HOME to for example /c/temp, then it will indeed be downloading some stuff in there (a cache folder and others). But that then still creates a ".gradle" directory in my project folder. I'm looking for a way to change that last directory.
Our project is structured as follows:
ROOT
│ ...
├── backend
│ ├── src
│ │ └──...
│ └── build.gradle
├── lib
│ ├── src
│ │ └──...
│ └── build.gradle
├── gradle
│ └── wrapper
├── gradlew
├── gradlew.bat
├── settings.gradle
The .gradle
folder which gets created the first time you run a gradle task is directly under the root folder. That's the one I'd like to control.
Why I want to do this?
In our pipelines (on github), we're using several templates which we do not have under our control. There's a template to build the code, one to run a sonar scan, etc..
Those templates also cache certain folders. And that's the place where we're currently getting a warning when the pipeline is trying to upload folders to be cached. I'm trying to get rid of that warning: WARNING: backend/.gradle: no matching files.
In our project, the .gradle folder is not being created in the backend folder, but in the root folder. If I have a way to configure where the .gradle folder is being created, the warning would be gone.
The templates are trying to cache the following 2 folders:
$GRADLE_USER_HOME/cache
(that is working as we are setting the GRADLE_USER_HOME env variable to the project directory)$CI_PROJECT_DIR/$CONF_WORK_DIRECTORY/.gradle
(this one causes the warning).