Gradle Wrapper distributionUrl


(david koch) #1

Hello, is there any chance to not have the distributionUrl but instead load it like an regular artifact from a maven repository?

The default distribution url is not reachable from our build environment. So I put the Gradle distro into a managed Nexus repository.

Now I have to make an hard link to this distributionUrl configuration. --David


Support for gradle wrapper distribution mirror
(Jochen Berger) #2

I like that idea, I’ve also wished for the possibility to specify multiple 'distributionUrl’s for cases like that (like a local mirror when building in one environment and the default ‘gradle.org’ distributionUrl when building somewhere else).


(Peter Niederwieser) #3

One thing to keep in mind is that the Gradle wrapper needs to stay small and simple (and compatible with a wide range of Gradle versions), and cannot have any external dependencies. So full Maven repository support is out of the question. It’s also not clear to me what advantages specifying a repository URL and Maven coordinates would have over specifying a distribution URL. Support for more than one distribution URL could potentially be added if there is a compelling use case.


(Jochen Berger) #4

The use case for me would just be being able to host a gradle distribution on a server in a network and still being able to build the project when the server is down or the build is started within a completely different network. If you could specify ‘distributionUrls=http://mymirror/build-resources/gradle/gradle-1.11-bin.zip,http://services.gradle.org/distributions/gradle-1.11-bin.zip’ and the urls were tried one after another, that would be possible. The advantage I would have seen in the repository-based approach would have been basically the same only that the mirror would have been selected depending on the project’s ‘repositories’.


(david koch) #5

My problem is that I have to maintain lots of projects. But there is always this somehow not so obvious place in the gradle-wrapper.properties file where I have to configure the complete url to the gradle distro to a private nexus repo (there is no access to internet) . When uprading the version the gradle version in the main build file, this url is completely overwritten.

I see that full maven support cannot be provided for this basic function. For my part it would be sufficient if I could just change the version in the gradle wrapper config so that it retains the distro url but just exchanges the version parts.

e.g. from 1.11

distributionUrl=http\://production/nexus/content/repositories/public-manual/org/gradle/gradle/1.11/gradle-1.11-bin.zip

to 2.0

distributionUrl=http\://production/nexus/content/repositories/public-manual/org/gradle/gradle/2.0/gradle-2.0-bin.zip

(Jochen Berger) #6

What if the version was another property in the properties file?

gradleVersion=1.11

distributionUrl=http://production/nexus/content/repositories/public-manual/org/gradle/gradle/${gradleVersion}/gradle-${gradleVersion}-bin.zip

or

gradleVersion=1.11

distributionUrls=http://mymirror/build-resources/gradle/gradle-${gradleVersion}-bin.zip,http://services.gradle.org/distributions/gradle-${gradleVersion}-bin.zip


(david koch) #7

I got it, sorry it was to simple:

task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
    distributionUrl = "http://production/nexus/content/repositories/public-manual/org/gradle/gradle/${gradleVersion}/gradle-${gradleVersion}-bin.zip"
}

(John Engelman) #8

Regarding multiple distributionUrls, what about this use case:

For local devs, point to the gradle--all.zip so that IDEs can display the source code for Gradle. For CI server point to the gradle--bin.zip so only what is required to build the code is downloaded.

A bit different from the idea of multiple locations to check for availability and would be more like an environment type block for the distributionUrl and the ability to pass the environment to the gradlew command, and set a default.