快速解決 GRADLE 項目下載 gradle-*-all.zip 慢的問題


 

 

1、首先根據項目中 gradle\wrapper\gradle-wrapper.properties 文件的 distributionUrl 屬性的值

#Tue Feb 06 12:27:20 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip

 

2、根據  distributionUrl  對應的 gradle 的版本好,去下載相應的版本,可以通過 迅雷 或者其他國內網站下載,下載后先保存在本地,等待后續使用

3、運行 gradle build 命令進行構建

# Windows 下使用 
gradlew.bat build 

# Linux mac 下使用 
gradlew build

運行以后,提示下載時,終止掉

 

終止掉后,打開此文件夾 $GRADLE_USER_HOME/wrapper/dists/gradle-4.8.1-bin/e8p42vx1m7a3mz9ydmjagn6wn 

橙色字體可能會和我不一樣,無所謂

提示:這個文件夾大多數都在用戶主目錄下 .gradle//wrapper/dists/... 下

4、在進入上一步說的文件夾以后先刪除所有文件,然后把第二步下載好的 zip 文件復制到此文件夾下 $GRADLE_USER_HOME/wrapper/dists/gradle-4.8.1-bin/e8p42vx1m7a3mz9ydmjagn6wn 。

5、再次執行 gradle build (注意 Windows 和 linux的命令不同),會變成如下,不需要再下載這個文件了,編譯會很快通過

C:\Users\duwenlei\IdeaProjects\spring_boot_demo
λ gradlew.bat build
Unzipping C:\Users\duwenlei\.gradle\wrapper\dists\gradle-4.8.1-bin\e8p42vx1m7a3mz9ydmjagn6wn\gradle-4.8.1-bin.zip to C:\Users\duwenlei\.gradle\wrapper\dists\gradle-4.8.1-bin\e8p42vx1m7a3mz9ydmjagn6wn

Welcome to Gradle 4.8.1!

Here are the highlights of this release:
 - Dependency locking
 - Maven Publish and Ivy Publish plugins improved and marked stable
 - Incremental annotation processing enhancements
 - APIs to configure tasks at creation time

For more details see https://docs.gradle.org/4.8.1/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

...

Download http://maven.aliyun.com/nexus/content/repositories/central/org/springframework/boot/spring-boot-starter-test/2.0.6.RELEASE/spring-boot-starter-test-2.0.6.RELEASE.jar

> Task :test
2018-10-25 23:34:55.551  INFO 588 --- [       Thread-5] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@413698fe: startup date [Thu Oct 25 23:34:52 CST 2018]; root of context hierarchy

BUILD SUCCESSFUL in 1m 5s
5 actionable tasks: 5 executed

 

6、完結,可以在通過 IDEA 或者其他編碼工具打開工程,跳過了慢悠悠的下載過程。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM