I'm looking to better isolate the Gradle user home...
# community-support
m
I'm looking to better isolate the Gradle user home in tests. Say I work on a Gradle plugin, and I want to test it with TestKit. I want the test to be reliable in CICD, so I don't want it to be polluted with my real
~/.gradle
. What I currently do is to populate
build/gradle
with what I need, namely
gradle.properties
, some
init.d/
scripts, and I point TestKit there with
withTestKitDir()
. This is mostly ok, except that the various Gradle distributions are downloaded in such test user home directories. This is annoying because it's slow the first time around, and also because these directories are not getting cleaned up. E.g. in 1 project after playing with only 9.2.0 and 9.2.1, I have almost 2GB of mostly generated Gradle jars and transforms. Is there a way to improve this? So basically, I don't care to isolate the Gradle artifacts and transforms from my primary Gradle user home, but I definitely want my user home properties and init scripts not to be visible in tests. Is there some way to achieve properties/init script isolation while also avoiding cache duplication?
t
m
Well, I do need some content in the test user home, specifically some init scripts to set up internal repo access. So the fact that TestKit uses an empty temp dir as user home by default is not really useful. For test invocations, I need to customize the properties and the init scripts, but I'd much rather share the rest of the primary user home dir, specifically generated jars and transforms. I don't think the issue can be resolved at TestKit level if there is no solution at Gradle level. Basically I want to use
~/.gradle/caches
but not
~/.gradle/init.d
. On Linux, I could try to hack this via symlinks, e.g.
build/gradle/caches => ~/.gradle/caches
but not on Windows. So what I'm really asking for is a way to configure the user home properties/init scrips separately from the user home caches, at Gradle level.
m
Nice, thanks, I'll give this a try.