How to properly write a gradle-wrapper.properties file?

sanjeev picture sanjeev · Jun 12, 2014 · Viewed 43.8k times · Source

Can anyone please tell me if there is any advantage of gradlew over gradle?

Also I have some doubts on the gradle-wrapper.properties file.

Initially when I ran

C:\project_basedir>gradle wrapper

I found the following content in gradle-wrapper.properties file.

#Thu Jun 12 17:06:10 IST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip

To stop downloading the zip file I have followed the steps as suggested in chapter 61.1. Configuration of gradle documentation and added the gradle-1.12-bin.zip file from my local gradle installation to <Project_Base>\gradle\wrapper directory. and modified the properties files as follows:

#Thu Jun 12 17:06:10 IST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=gradle-1.12.zip

It saved the downloading time.

My Gradle installtion structure is as below:

C:\Users\sanjeev\Softwares\Gradle\gradle-1.12\bin

I have set system property GRADLE_USER_HOME to my local installtion dir i.e. C:\Users\sanjeev\Softwares\Gradle\gradle-1.12. But the distributionBase & distributionPath options are not picking the value.

I even tried to modify the values as:

distributionBase=file://C://Users//sanjeev//Softwares//Gradle//gradle-1.12

It did not work.

Exception in thread "main" java.lang.RuntimeException: Base: file:/C:/Users/sanjeev/Softwares/Gradle/gradle-1.12 is unknown

Can someone please suggest what am I missing here?

Or in a nutshell how to define distributionBase,distributionPath,zipStoreBase and zipStorePath properly?

Answer

mikea picture mikea · Jun 12, 2014

The advantage of gradlew over gradle is that:

  1. You don't have to have gradle installed on your machine in order to build your project.
  2. You can control which version of gradle is needed to build your project.

I'm not sure of the point of changing the distribution url in the properties file. The whole point of the wrapper is that it downloads gradle. If you get it locally you might as well install and use gradle instead. The wrapper will only download the distribution once anyway and store it for each user (hence the use of GRADLE_USER_HOME).

GRADLE_USER_HOME is an environment property, not a system property. If you want to change the gradle user home using system properties you need to set 'gradle.user.home'.