Loading

Gradle全局变量定义及引用

在Project的build.gradle脚本中定义一些全局变量

ext {
    compileSdkVersion = 21
    buildToolsVersion = "24.0.1"
    minSdkVersion = 9
    targetSdkVersion = 19
    versionCode = 29
    versionName = '3.1.0'
    targetCompatibility = 1.7
    sourceCompatibility = 1.7
}

在Module的build.gradle脚本中调用

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion"
        buildConfigField "String", "BUILD_DATE", "\"${new Date().toLocaleString()}\"";
        multiDexEnabled true
    }
}

 

posted @ 2017-01-02 17:07  辉灬  阅读(7437)  评论(0编辑  收藏  举报