I want to add an init script to a repository, but ...
# community-support
a
I want to add an init script to a repository, but I don't want to add it to git. The docs say "Put a file called
init.gradle(.kts)
in the
$GRADLE_HOME/init.d/
directory." What is
GRADLE_HOME
? Is it
$projectDir/.gradle/
?
e
it's a link in the docs there, you can click on it. no, it's the home of the gradle installation. which is generally in the distribution downloaded by the gradle wrapper, so not something you'll be adding to (unless you build your own custom gradle distribution)
$GRADLE_USER_HOME
is something that you can much more easily edit, as it's
~/.gradle
by default
a
does the link work for you?
e
yes the link works for me
a
Adding an init script to GUH is an option, but then it will affect every project, and init scripts negatively impact config cache
ah okay, the link works for Chrome but not Firefox
e
there isn't a project-specific init.d folder. https://github.com/gradle/gradle/issues/17826
a
thanks
r
what you can do is to use conditions in your init script and only add configuration/repositories/code if eg. the project name matches. I would also recommend using logging so you can see if it is added the config or not 🙂