Gradle 學習 三
遠程倉庫 jcenter和mavenCentral
mavenCentral的地址:http://mvnrepository.com/
本地私有倉庫maven
buildscript { repositories { mavenLocal() maven { url "http://mvnrepository.com" } jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { mavenLocal() maven { url "http://mvnrepository.com" } jcenter() mavenCentral() } }
本地arr依賴
1)新建module之後,編譯通過後
2)選擇工程 new module->import arr
3)build.gradle中加入 compile project(‘:arr名字’)
使用Gradle上傳arr到Maven庫 暫略
Gradle依賴庫緩存
不懂 ./gradle文件夾裏面存儲緩存??
Gradle通知機制
compile('org.springframework:spring-web:5.0.0.RELEASE') { transitive = true //去除在下載spring-web時,是否下載其它的springframework組件 }
Gradle的依賴檢查
grdlew androidDependencies 可以簡寫爲gradle androidD
顯示依賴關係圖
Gradle的依賴傳遞
不懂 用了幾個方法不好用
Gradle依賴的統一參數管理
在根目錄build.gradle中
ext { android = [cSV: 26, bTV: '26.0.1'] dependencies=[v7:'com.android.support:appcompat-v7:26.+'] }
在app目錄build.gradle中引用這些值
compileSdkVersion rootProject.ext.android.cSV buildToolsVersion rootProject.ext.android.bTV compile rootProject.ext.dependencies.v7
也可以單獨寫一個文件,但是需要在app目錄build.gradle中引用這個文件apply from:’xxx.gradle’ xxx.gradle文件名