抽取公共gradle进行版本控制方便进行统一管理

  • 1.首先创建一个config.gradle文件

现在只需修改config.gradle文件版本号

ext {


    android = [

            compileSdkVersion    : 24,
            buildToolsVersion    : "24.0.2",
            minSdkVersion        : 15,
            targetSdkVersion     : 23,
            versionCode          : 1,
            versionName          : "1.0",


            androidSupportVersion: "25.2.0",
            retrofitVersion      : "2.2.0",
            butterknifeVersion   : "8.5.1",
            rxJavaVersion        : "2.0.7",
            rxAndroidVersion     : "2.0.1",
            rxbindingVersion     : "2.0.0",
            okhttpVersion        : "3.6.0",

    ]



    dependencies = [

            "appcompat-v7"              : "com.android.support:appcompat-v7:${android["androidSupportVersion"]}",
            "design"                    : "com.android.support:design:${android["androidSupportVersion"]}",

            "retrofit"                  : "com.squareup.retrofit2:retrofit:${android["retrofitVersion"]}",
            "retrofit-adapter-rxjava"   : "com.squareup.retrofit2:adapter-rxjava2:${android["retrofitVersion"]}",
            "retrofit-converter-gson"   : "com.squareup.retrofit2:converter-gson:${android["retrofitVersion"]}",

            "okhttp"                    : "com.squareup.okhttp3:okhttp:${android["okhttpVersion"]}",
            "okhttp-logging-interceptor": "com.squareup.okhttp3:logging-interceptor:${android["okhttpVersion"]}",



            "butterknife"               : "com.jakewharton:butterknife:${android["butterknifeVersion"]}",
            "butterknife-compiler"      : "com.jakewharton:butterknife-compiler:${android["butterknifeVersion"]}",

            "rxjava"                    : "io.reactivex.rxjava2:rxjava:${android["rxJavaVersion"]}",
            "rxandroid"                 : "io.reactivex.rxjava2:rxandroid:${android["rxAndroidVersion"]}",
            "rxbinding"                 : "com.jakewharton.rxbinding2:rxbinding:${android["rxbindingVersion"]}",

    ]


}
  • 2.其次在Project级别build.gradle加入引用config.gradle配置
apply from : "config.gradle"
  • 3.其次在Module级别build.gradle下载包
apply plugin: 'com.android.application'
//apply plugin: 'com.neenbedankt.android-apt'//添加apt命令
apply plugin: 'android-apt'

android {
    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
    buildToolsVersion rootProject.ext.android["buildToolsVersion"]
    defaultConfig {
        applicationId "cainiao.phoneassistant"
        minSdkVersion rootProject.ext.android["minSdkVersion"]
        targetSdkVersion rootProject.ext.android["targetSdkVersion"]
        versionCode rootProject.ext.android["versionCode"]
        versionName rootProject.ext.android["versionName"]
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'




    compile rootProject.ext.dependencies["appcompat-v7"]
    compile rootProject.ext.dependencies["design"]

    compile rootProject.ext.dependencies['butterknife']
    apt rootProject.ext.dependencies['butterknife-compiler']

    compile rootProject.ext.dependencies['retrofit'] // 需要升级
    compile rootProject.ext.dependencies['retrofit-adapter-rxjava']// 需要升级
    compile rootProject.ext.dependencies['retrofit-converter-gson']


    compile rootProject.ext.dependencies["okhttp"]  // 需要升级
    compile rootProject.ext.dependencies["okhttp-logging-interceptor"]

    compile rootProject.ext.dependencies["rxjava"]
    compile rootProject.ext.dependencies["rxandroid"]

    compile rootProject.ext.dependencies["rxbinding"] // 需要升级

//    compile 'com.hwangjr.rxbus:rxbus:1.0.5'  // 去掉

//    compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.1@aar'
    compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.8.2@aar' //降级


    compile 'com.google.dagger:dagger:2.6'
    apt 'com.google.dagger:dagger-compiler:2.6'


    compile 'com.jaeger.statusbaruitl:library:1.2.5'

    compile('com.mikepenz:materialdrawer:5.6.0@aar') {
        transitive = true
    }
    compile 'com.mikepenz:iconics-core:2.8.1@aar'
    compile 'com.mikepenz:ionicons-typeface:2.0.1.2@aar'

    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'

    compile 'jp.wasabeef:glide-transformations:2.0.1'
    compile 'cn.pedant.sweetalert:library:1.3'

    compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.0'
    compile 'com.zoonref:simple-view-behavior:1.0'
    compile 'com.ms-square:expandableTextView:0.1.4'

    //pathview
    compile 'com.eftimoff:android-pathview:1.0.8@aar'

//    compile project(path: ':rxdownload')
}

//dependencies {
//    compile fileTree(include: ['*.jar'], dir: 'libs')
//    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
//        exclude group: 'com.android.support', module: 'support-annotations'
//    })
//    testCompile 'junit:junit:4.12'
//    compile rootProject.ext.dependencies["appcompat-v7"]
//    compile rootProject.ext.dependencies["design"]
//
//    //butterknife
//    compile 'com.jakewharton:butterknife:8.4.0'
////    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
//    apt 'com.jakewharton:butterknife-compiler:8.4.0'
//
//    // icon
//    compile 'com.mikepenz:iconics-core:2.8.1@aar'
//    compile 'com.mikepenz:ionicons-typeface:2.0.1.2@aar'
//
//    //RxJava
//    compile 'io.reactivex:rxandroid:1.2.1'
//    compile 'io.reactivex:rxjava:1.1.6'
//
//    //retrofit
//    compile 'com.squareup.retrofit2:retrofit:2.1.0'
//    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
//    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//
//    // okHttp
//    compile 'com.squareup.okhttp3:okhttp:3.4.1'
//    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
//
//    //picasso
//    compile 'com.squareup.picasso:picasso:2.5.2'
//
//    //dagger2
//    apt 'com.google.dagger:dagger-compiler:2.0.2' //指定注解处理器
//    compile 'com.google.dagger:dagger:2.0.2'  //dagger公用api
//    provided 'org.glassfish:javax.annotation:10.0-b28'  //添加android缺失的部分javax注解
//
//    //pathview
//    compile 'com.eftimoff:android-pathview:1.0.8@aar'
//
//    //sweet-alert-dialog
//    compile 'cn.pedant.sweetalert:library:1.3'
//
////    RxPermissions
//    compile 'com.tbruyelle.rxpermissions:rxpermissions:0.9.1@aar'
//
//    //glide
//    compile 'com.github.bumptech.glide:glide:3.7.0'
//    compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
//    compile 'jp.wasabeef:glide-transformations:2.0.1'
//
//    //BaseQuickAdapter
//    compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.0'
//
//    //rxbinding
//    compile 'com.jakewharton.rxbinding:rxbinding:1.0.1'
//
//    //rxbus
//    compile 'com.hwangjr.rxbus:rxbus:1.0.5'
//
//    compile 'com.ms-square:expandableTextView:0.1.4'
//
//    compile 'com.zoonref:simple-view-behavior:1.0'
//}

你可能感兴趣的:(抽取公共gradle进行版本控制方便进行统一管理)