Skip to content

Instantly share code, notes, and snippets.

@autonomousapps
Last active August 20, 2020 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save autonomousapps/209dee9be7e3a3c9de9611b811443e68 to your computer and use it in GitHub Desktop.
Save autonomousapps/209dee9be7e3a3c9de9611b811443e68 to your computer and use it in GitHub Desktop.
Using a custom Gradle distribution
# How do I package a custom Gradle distribution with init scripts?
I want to be able to configure Gradle Enterprise, build scans, and the cache, all from one centralized location.
# Answer
In order to customize your Gradle distribution, you basically have to add one or more init scripts to the `init.d/` directory in the distribution `.zip` file. That's talked about here:
https://docs.gradle.org/current/userguide/init_scripts.html#sec:using_an_init_script
> Put a file that ends with `.gradle` (or `.init.gradle.kts` for Kotlin) in the `GRADLE_HOME/init.d/` directory, in the Gradle distribution. This allows you to package up a custom Gradle distribution containing some custom build logic and plugins. You can combine this with the Gradle wrapper as a way to make custom logic available to all builds in your enterprise.
The actual script would look something like **Example 9** from https://docs.gradle.org/current/userguide/build_cache.html#sec:build_cache_configure_remote
And we talk about packaging custom distributions at https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:custom_gradle_distribution
Here's a code sample of how to download the standard Gradle distribution and re-package as a custom distribution: https://github.com/gradle/gradle/tree/master/subprojects/docs/src/samples/userguide/organizingGradleProjects/customGradleDistribution
**So, basically, here are the steps:**
1. Write an init script that customizes any settings you care about.
2. Put that in the `init.d/` directory of your custom distribution.
3. Profit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment