acejazz
acejazz

Reputation: 819

How to include a Gradle distribution in the project to be used for the wrapper

I want to include a specific version of Gradle in the project folder so that when I use the Gradle wrapper it doesn't download it from the remote repository.

I downloaded the version of Gradle I need (gradle-4.0-bin.zip) and I put that zip fine inside of gradle/wrapper/ folder of the project (created with the gradle wrapper command). Then I edited the gradle-wrapper.properties file in this way:

distributionUrl=file:///Users/pathj/to/the/project/gradle/wrapper/gradle-4.0-bin.zip

But when I run the first command, such as gradle task it returns:

  • What went wrong: A problem occurred configuring root project '03-gradle-wrapper-local'.

    java.io.FileNotFoundException: /Users/myself/.gradle/wrapper/dists/gradle-4.0-bin/3p92xsbhik5vmig8i90n16yxc/gradle-4.0/lib/plugins/gradle-diagnostics-4.0.jar (No such file or directory)

How do I tell Gradle to get the zip file from the current project folder, with a relative path, instead of downloading it, and to use that zip file to create a wrapper to be used in my builds?

Upvotes: 1

Views: 2446

Answers (1)

Opal
Opal

Reputation: 84756

Apart from storing gradle wrapper locally make sense or not it is possible. I assume that gradle-4.0-rc-3-bin distro is used.

Here is the project structure:

.
├── gradle
│   └── wrapper
│       ├── gradle-4.0-rc-3-bin.zip
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
└── gradlew.bat

And here the content of gradle-wrapper.properties:

distributionBase=PROJECT
distributionPath=gradle
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=gradle-4.0-rc-3-bin.zip

Since wrapper files will be downloaded to the project dir adding gradle/gradle-4.0-rc-3-bin to SCM ignore file is recommended.

Demo can be found here.

Upvotes: 2

Related Questions