Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use gradle zip in local system without downloading when using gradle-wrapper

Tags:

gradle

gradlew

I'm trying to build a gradle project with gradle-wrapper (gradlew).

When I build with ./gradlew build, it outputs text

Downloading http://services.gradle.org/distributions/gradle-1.11-bin.zip

And I already got gradle-1.11-bin.zip downloaded separately and I don't want to be downloading it again when I build.

So, where shall I put gradle-1.11-bin.zip in my project or system so that I don't have to download again?

gradle/wrapper/gradle-wrapper.properties is as following.

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip 

And I've tried copying gradle-1.11-bin.zip into gradle/wrapper/dists which didn't solve the problem.

like image 347
TheKojuEffect Avatar asked Apr 06 '14 16:04

TheKojuEffect


People also ask

Where does Gradle wrapper download?

By default GRADLE_USER_HOME is ~/. gradle , so the wrapper will store Gradle distributions at ~/. gradle/wrapper/dists .

Do I need Gradle wrapper?

you don't need to have Gradle installed on your machine to build the project. the wrapper guarantees you'll be using the version of Gradle required by the project. you can easily update the project to a newer version of Gradle, and push those changes to version control so other team members use the newer version.

How do I use Gradle wrapper command?

To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … ​ e.g. gradlew clean allTests.


2 Answers

From gradle-wrapper documentation, I found in section 61.1. Configuration

If you don't want any download to happen when your project is build via gradlew, simply add the Gradle distribution zip to your version control at the location specified by your wrapper configuration. A relative URL is supported - you can specify a distribution file relative to the location of gradle-wrapper.properties file.

So, I changed distributionUrl property in gradle-wrapper.properties to

distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=gradle-1.11-bin.zip 

Then, I made a copy of gradle-1.11-bin.zip in gradle/wrapper/.

Then, ./gradlew build downloaded local copy of zip and built the project.

like image 108
TheKojuEffect Avatar answered Nov 05 '22 14:11

TheKojuEffect


Modifty the gradle/gradle-wrapper.properties

Windows:

distributionUrl=file\:/d:/gradle-2.2.1-all.zip 

linux:

distributionUrl=file\:/tmp/gradle-2.2.1-all.zip 
like image 27
wcc526 Avatar answered Nov 05 '22 13:11

wcc526