Avoiding ".gradle" folder creation under project folder structure

Answered

Hey all,

 

TL;DR

How do I make sure that IDEA will not create the `.gradle` folder under the project's folder structure?

 

Background

I'm trying to stop gradle from writing temporary files under the project's folder structure (i.e: the `build` & `.gradle` folders).

Getting rid of the `build` folder was easy.

But getting rid of the `.gradle` folder is trickier.
I changed the `gradlew` and `gradlew.bat` scripts under the project to invoke gradle using: `--project-cache-dir=<some folder outside of the project>`.

When I execute `gradlew` from the terminal, everything works fine (the cache is written to the desired location outside of the project).
But when IDEA runs gradle (either manually or via auto import) the `.gradle` folder keeps coming back.

Shouldn't IDEA use the `gradlew` scripts under the project root to invoke gradle when it's configured with `use default gradle wrapper`?
What am I missing here?

 

Configuration

IDEA gradle configuration (Using IDEA version: 2018.1.6 CE):

Thanks!

Shai.

 

0
3 comments

IntelliJ IDEA doesn't run Gradle directly, it uses the specialized tooling API from Gradle to introspect the project configuration and convert it into IntelliJ IDEA project model. Options in the command line files will have zero effect.

There doesn't seem to be a way to set it via build scripts/API, see https://discuss.gradle.org/t/latest-point-at-which-projectcachedir-can-be-set/ for the related discussion.

Feature request is welcome at https://youtrack.jetbrains.com/issues/IDEA.

1
Avatar
Permanently deleted user

Hi, what's the fix for this? I'm running into a similar issue as well.

I already have a .gradle directory in my user home that has properties in it - but IntelliJ keeps creating a new one, meaning there's no access to my properties file, which causes my builds to fail.

 

0

@Cjcastil it is not possible to customize it now with current Gradle API. You are welcome to file a request at https://youtrack.jetbrains.com/issues/IDEA describing your use-case. Thank you.

0

Please sign in to leave a comment.