I have just joined a new project where my employer is collaborating with external service provider to jointly build some software. One of our critical requirements is that each side should be able to take the codebase and go their own way at any moment in time.
To this end, we are maintaining separate artifact repository, parameterizing the repo URL in build.properties
and provide the appropriate details in user-specific gradle.properties
. We also got rid of the plugin-portal DSL usage, so things are almost there. It is up to you to figure how to launch the correct jar file.
There is only one catch… as nice as it is, the Gradle wrapper.properties
only allow us to have a single download URL and does not provide any mechanisms for customization. I am putting the problem here here as an open question, though a few solutions that come to mind are:
Variant A: have the Gradle wrapper resolve stuff from gradle.properties
in the same way the main Gradle does, so we could specify:
distributionUrl = https://${repo.wrapper}/org/gradle/2.5/gradle-2.5-bin.zip
Variant B: allow to provide a list of download URLs that would be tried in order (similar to how builds may specify multiple repos).
The list can be implemented by either allowing coma separated values and stripping spaces, such as:
distributionUrl = https://mycompany.com/repo/public/gradle-2.5-bin.zip, \
https://theircompany.com/repo/3rd-party/gradle-2.5-bin.zip, \
https://services.gradle.org/distributions/gradle-2.5-bin.zip
or if we don’t want to parse the values, perhaps use numbered properties such as:
distributionUrl = https://mycompany.com/repo/public/gradle-2.5-bin.zip
distributionUrl.fallback.1 = https://theircompany.com/repo/3rd-party/gradle-2.5-bin.zip
distributionUrl.fallback.2 = https://services.gradle.org/distributions/gradle-2.5-bin.zip
Variant C: allow reference to environment variables, such as:
distributionUrl = https://${env:GRADLE_WRAPPER_REPO}/org/gradle/2.5/gradle-2.5-bin.zip
Variant D: allow multiple wrapper.properties
files and use filename pattern to try them in alphabetical order. This has the benefit that each client can customize not only the distribution URL, but also the checksum, download location (i.e. in case of disk quotas or roaming profiles), etc.
Edit: Variant D is almost available - if you have multiple copies of wrapper.jar
file, each jar would use a corresponding properties file with the same base name.