Put init.gradle in wrapper?

The Gradle User’s Guide Section 42.2 offers that I may

Put a file that ends with .gradle 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.

Is there an example of combining this with the gradle wrapper? I am interested in doing this as I am in the process of developing a system-wide configuration and I want to store this (at least for now) with the proof-of-concept project I am developing with gradle. I want to check it into our git repository.

I see a similar question was asked in 2012. Is this still the state of the art, or is there more that can be said about it now?

We use this technique where I work. We package every new Gradle version with our own scripts in init.d (setting up the location for our binary repo, typical buildscript dependencies, etc.). When setting up projects, we require that developers point their gradle-wrapper.properties to our internal distribution:


Let me know if you’d like more details.


Yes, please, I would like to see your setup. This sounds maybe not quite what I’m looking for. My main development goal here is to develop the global init,gradle within the context of a single multi-project build, with the idea of eventually globalizing it. Since I am also using version control (with very frequent commits!) as an easy way of moving the whole system from my workstation to the server on which the builds and tests run (to which I have only terminal access), I want this file to live (temporarily) WITHIN the project, so it migrates with the rest of the project through the git repo. Much easier/faster than ftp/sftp, etc.

None of the init possibilities I see mentioned seem to handle this case.

The best I am able to come up with so far, is to physically locate this file within the project and specify on the command line where to find it, wrapping all this up in an alias for ease of use.

But it would be nicer if it could somehow be located in the wrapper.

I realize this is an unusual case and one that I don’t even want to be using once I’m done with this phase.


Below is the gist of the build script that repackages Gradle for our internal use (originally provided by @sterling) . I’ve removed 1) stuff that’s specific to our own internal plugins -and- 2) a bunch of Artifactory-related stuff that we use to publish the distribution to our internal repository.

Hope this helps


apply plugin: 'base'

wrapper {
    gradleVersion = '2.10'
    distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-bin.zip"

group = 'com.foo'
description = 'Internal Gradle Distribution'

task downloadGradleDist(type: UrlDownload) {
    url = wrapper.distributionUrl
    destination = file("$buildDir/gradle.zip")

task repackageGradle(type: Zip, dependsOn: downloadGradleDist) {
    into("gradle-$wrapper.gradleVersion") { from("init.d") { into "init.d" } }

class UrlDownload extends DefaultTask {
    UrlDownload() {
        onlyIf { !destination.exists() }

    @Input String url
    @OutputFile File destination

    void doDownload() {
        getDestination().withOutputStream { out ->
            new URL(getUrl()).withInputStream { out << it }


It’s five years later, there’s no way better to encapsulate this and use properly the init.d folder with the wrapper?

For instance looking for it on the gradle folder (same level as wrapper), or even allowing the a init.gradle at the project root.