is there a way I should get the location of the `&...
# community-support
c
is there a way I should get the location of the
<repo>/.gradle
directory? is there anything that say I can't make a subdirectory in there?
t
Didn't Vampire previously pointed you to
gradle.startParameters.projectCacheDir
, also pointing out that Gradle says you shouldn't store arbitrary things in there? https://docs.gradle.org/current/javadoc/org/gradle/StartParameter.html#getProjectCacheDir()
☝️ 1
c
that's the cacheDir, I'm just asking about
.gradle
which is more than
.gradle/caches
so my though is if I make
.gradle/com.xenoterracide.something/
the question is subtly different 😉
same root problem though
t
There's no
.gradle/caches
in the project (you said
<repo>
above), the whole
.gradle
is the cache dir. See
--project-cache-dir
in https://docs.gradle.org/current/userguide/command_line_interface.html#sec:environment_options, also https://docs.gradle.org/current/userguide/directory_layout.html#dir:project_root
Did you actually mean the Gradle User Home dir?, i.e.
~/.gradle/
? https://docs.gradle.org/current/userguide/directory_layout.html#dir:gradle_user_home Then I think you can store things inside; I believe the AGP and KGP already do such thing.
c
sorry, I was accidentally in ~ and didn't realize it when I did
ls
why obsess with the cachedir
there's more than caches in there
Copy code
❯ ls .gradle 
8.10.2              configuration-cache  noVersion  workspace-id.txt
buildOutputCleanup  file-system.probe    vcs-1      workspace-id.txt.lock
the alternative is for me to get the
rootProject
dir and fetch from there
unless .gradle is the cache dir as it is
whole thing is annoying
t
Whether there's only caches or more than caches, Gradle calls it "project-specific cache dir" and tells you not to use it 🤷
c
gotcha, I presumed it was a subdir, I'll use the gradle homedir or whatever then. Just need to design this structure right
t
I have no idea what your use case is, but I for one see no problem using something like
$rootDir/.my-own-cache
(as long as it's duly documented for users) if you feel
${rootProject.buildDir}/my-own-cache
won't work for you for whichever reason. And if that cache is project-independent, then store somewhere in the user home (possibly in the Gradle User Home dir)
c
it's dependent, but I can easily write the code so that it's not, it needs to last longer than a build
I've thought about using the XDG spec, but that's OS problematic
a
If it helps, there a library for getting OS specific directories https://github.com/harawata/appdirs I've been considering using it to get the correct OS cache dir for my application.
(there's also https://github.com/dirs-dev/directories-jvm which is similar, but it doesn't work well on Windows, unless you use the lates release which requires Java 22+)
c
Yeah I was looking at the ladder but the 22 plus isn't going to work for me. I mean it could work for me... But I'd like this stuff to work for other people 😉