Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
507 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...