Intellij IDEA 安裝配置Gradle

1.安裝html

到官網連接下載最新的bin版本,解壓到緩存

D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\gradle

配置環境變量jvm

GRADLE_HOME=D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\gradle

GRADLE_USER_HOME=D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\.gradle

注意上面的配置測試

第一個是gradel,是gradle的安裝路徑gradle

第二個是.gradle,注意前面有個點號,這個文件是用來存放Gradle緩存的ui

將下面的配置添加到Path路徑中:this

D:\Program Files (x86)\JetBrains\IDEA Configuration And Cache\gradle\bin

使用gradle -v 命令查看:spa

C:\Users\qhong\Desktop
$ gradle -v

Welcome to Gradle 4.9!

Here are the highlights of this release:
 - Experimental APIs for creating and configuring tasks lazily
 - Pass arguments to JavaExec via CLI
 - Auxiliary publication dependency support for multi-project builds
 - Improved dependency insight report

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


------------------------------------------------------------
Gradle 4.9
------------------------------------------------------------

Build time:   2018-07-16 08:14:03 UTC
Revision:     efcf8c1cf533b03c70f394f270f46a174c738efc

Kotlin DSL:   0.18.4
Kotlin:       1.2.41
Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_102 (Oracle Corporation 25.102-b14)
OS:           Windows 10 10.0 amd64

在我們的gradle緩存.gradle目錄下建立一個gradle.properties 文件 ,再打開該文件在其中添加以下語句,能夠提升編譯速度。.net

#開啓線程守護,第一次編譯時開線程,以後就不會再開了
org.gradle.daemon=true
#配置編譯時的虛擬機大小
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#開啓並行編譯,至關於多條線程再走
org.gradle.parallel=true
#啓用新的孵化模式
org.gradle.configureondemand=true

 

2.IDEA配置:線程

Service directory path:就配置到放gradle緩存的地方。

Offline work:離線工做,在包全都下載之後能夠設置,這樣效率高些。

3.Gradle命令

gradle -v                  //版本號
gradle clean               //清除build文件夾
gradle build               //檢查依賴並打包
gradle assembleDebug       //編譯打包Debug包
gradle assembleRelease     //編譯打包Release包
gradle installRelease      //打包並安裝Release包
gradle unstallRelease      //卸載Release包
gradle dependencies        //查看依賴圖表
gradle clean build -x test //跳過測試編譯
gradle --profile build     //分析構建任務
gradle build --dry-run     //編譯並不執行任務
gradle install             //安置項目jar包到本地Maven倉庫
gradle tasks               //查看Gradle任務
gradle tasks --all         //查看全部Gradle任務
gradle build --daemon      //使用Gradle守護程序(Daemon)
gradle build --offline     //用離線模式運行
gradle clean build --refresh-dependencies     //刷新Gradle依賴緩存

 

參考:

https://services.gradle.org/distributions/

https://blog.csdn.net/x_iya/article/details/75040806

http://www.javashuo.com/article/p-eoxirxhu-cg.html

https://blog.csdn.net/yanzi1225627/article/details/52024632

https://www.jianshu.com/p/109dfedd56c8

http://daking.tech/2017/03/10/Gradle%E7%AC%94%E8%AE%B03%EF%BC%9AGradle%E5%91%BD%E4%BB%A4/

相關文章
相關標籤/搜索