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

后端 未结 10 1777
走了就别回头了
走了就别回头了 2020-12-04 06:29

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

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

10条回答
  •  Happy的楠姐
    2020-12-04 07:03

    This is what I did to avoid editing all gradle wrapper for current and future projects.

    • Locate your gradle-wrapper.properties in your project folder (eg. ./gradle/wrapper/gradle-wrapper.properties)
    • open the file with a text editor like Sublime Text to locate the distributionUrl line (eg. distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-bin.zip

    The gradle binary archive needed is gradle-2.10-bin.zip. Another version is gradle-2.10-all.zip that includes everything including source code and documentation.

    Please note each project ships with different versions of gradle distributions and you can change the version to the one you have (gradle-x.xx-XXX.zip) that include the binary. (eg. gradle-2.11-bin.zip | gradle-2.11-all.zip ).

    Execute gradlew.bat on window or gradle on linux to start the wrapper to build the project.

    It will begin downloading the gradle-2.10-bin.zip to the .gradle\wrapper\dists in your home directory (eg.C:\Users\Sojimaxi\.gradle\wrapper\dists\gradle-2.10-bin). This download happens just once for each specified gradle version.

    If you already downloaded the archive before you can terminate the download using Ctrl+C

    Go into the gradle download location C:\Users\Sojimaxi\.gradle\wrapper\dists\gradle-2.10-all\78v82fsf226usgvgh7q2ptcvif copy your own copy of gradle-2.10-bin.zip into that directory then delete the gradle-2.10-all.zip.part in that directory.

    That's all. Go back to your project directory to execute gradlew.bat and it will use your local copy instead of downloading a new one.

提交回复
热议问题