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

4

19

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.zip

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?

Forbiddance answered 12/6, 2014 at 12:36 Comment(0)
P
21

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'.

Pirri answered 12/6, 2014 at 12:49 Comment(0)
R
4

The best way to get a proper gradle-wrapper.properties is to run the wrapper task using gradle wrapper. But that needs a local gradle installation. When editing the content of that file manually you need to be careful with escaping. Try this distributionUrl:

distributionUrl=file\://gradle/wrapper/gradle-1.12-bin.zip

One more comment: It might be easier to maintain if you put your gradle installation in a local bin repository (e.g in your nexus or artifactory repository) and let gradlew download the referenced gradle bin from there. The benefit is, that you just need to update the distributionURL.

Rosales answered 12/6, 2014 at 13:32 Comment(0)
Q
2

If you're trying to change your wrapper distributionUrl to point at your local Gradle.zip file.

(Without spaces) Change it to file \ : ///C:\Users\sanjeev\Softwares\Gradle\gradle-1.12.zip (the filename gradle-1.12.zip here must be the same as how it is in your PC.)

Quianaquibble answered 15/9, 2016 at 14:1 Comment(1)
Remove the spaces between file \ :Quianaquibble
S
1

Remove spaces as shown below, or it wont work :

distributionUrl= file\:///c:/Users\sanjeev\Softwares\Gradle\gradle-1.12.zip
Serge answered 22/2, 2021 at 4:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.