[RESOLVED] Gradle wrapper version check too strict to work with custom Gradle distributions


Recently, we experimented with creating a custom Gradle distribution that is essentially a standard Gradle distribution of some version, say 2.6, extended by a custom init script placed in the init.d folder. Because such a customized Gradle distribution is not the same as the original one (distributed via gradle.org), we extended its version by simply appending a suffix: say the original version is 2.6, we changed it to 2.6-1. The reason is that we don’t want to tie the Gradle version and the version of our init script together: if the init script changes then we might want to deploy a new distribution based on the same Gradle version, say 2.6-2 (note that 2.6.1, 2.6.2, … should not be used in this case since this would be Gradle patch releases).

However, configuring the wrapper task with such version numbers (in order to configure a project to use our custom distribution)

wrapper {
	gradleVersion = '2.6-1'
	distributionUrl = 'https://repos.we.com/artifactory/main/com/we/gradle/gradle/2.6-1/gradle-2.6-1-bin.zip'

results in the following exception:

java.lang.IllegalArgumentException: '2.6-1' is not a valid Gradle version string (examples: '1.0', '1.0-rc-1')
	at org.gradle.util.GradleVersion.(GradleVersion.java:103)
	at org.gradle.util.GradleVersion.version(GradleVersion.java:93)
	at org.gradle.api.tasks.wrapper.Wrapper.setGradleVersion(Wrapper.java:209)
	at org.gradle.api.tasks.wrapper.Wrapper_Decorated.setGradleVersion(Unknown Source)
	at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.setProperty(BeanDynamicObject.java:194)
	at org.gradle.api.internal.BeanDynamicObject.setProperty(BeanDynamicObject.java:111)
	at org.gradle.api.internal.CompositeDynamicObject.setProperty(CompositeDynamicObject.java:104)
	at org.gradle.api.tasks.wrapper.Wrapper_Decorated.setProperty(Unknown Source)
	at init_ci6ucyu5x9mt06vuywawa2v29$_run_closure2_closure12_closure13.doCall(/Users/th/.gradle/init.gradle:94)

The question to me is what is the reason for this check by the wrapper task? Following the principle of being liberal in what you accept (and conservative in what you do), I would expect that any version string is allowed here. What do you think?

There’s no need to specify both gradleVersion and distributionUrl. In this case you can simply provide the latter. The gradleVersion property is primarily for convenience if you are using the standard Gradle distribution and don’t want to supply the full URL.

Thanks, Mark. Didn’t knew that. That resolves this issue.