Gradle 學習 三

Gradle 學習 三

  1. 遠程倉庫 jcenter和mavenCentral

    mavenCentral的地址:http://mvnrepository.com/

  2. 本地私有倉庫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()
       }
    }
  3. 本地arr依賴

    1)新建module之後,編譯通過後

    2)選擇工程 new module->import arr

    3)build.gradle中加入 compile project(‘:arr名字’)

  4. 使用Gradle上傳arr到Maven庫 暫略

  5. Gradle依賴庫緩存

    不懂 ./gradle文件夾裏面存儲緩存??

  6. Gradle通知機制

    compile('org.springframework:spring-web:5.0.0.RELEASE') {
       transitive = true //去除在下載spring-web時,是否下載其它的springframework組件
    }
  7. Gradle的依賴檢查

    grdlew androidDependencies 可以簡寫爲gradle androidD

    顯示依賴關係圖

  8. Gradle的依賴傳遞

    不懂 用了幾個方法不好用

  9. 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文件名

發佈了70 篇原創文章 · 獲贊 3 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章