Android studioAndroid开发经验谈Android开发

Android build.gradle 使用 Svn,Git

2017-10-31  本文已影响63人  coolfireApy

Svn

def getSvnRevisionNumber() {
    return 'svn info --show-item revision'.execute().text.trim()
}
def getSvnVersionInfo() {
    return 'svn log -r HEAD'.execute().text.trim()
}

Git

def gitGitVersionCode() {
    return 'git rev-list HEAD --first-parent --count'.execute().text.trim().toInteger()
}
def getGitVersionName() {
    try {
        def stdout = new ByteArrayOutputStream()
        exec {
            commandLine 'git', 'describe', '--tags'
            standardOutput = stdout
        }
        return stdout.toString().trim()
    }
    catch (ignored) {
        return "1.0.0"
    }
}
def getGitVersionInfo() {
    return 'git rev-parse --short HEAD'.execute().text.trim()
}

build.gradle中使用Git提交记录

    //默认配置
    defaultConfig {
        applicationId "com.huyingbao.simple"
        multiDexEnabled true//支持Multidex分包
        minSdkVersion MIN_SDK_VERSION as int
        targetSdkVersion TARGET_SDK_VERSION as int
        versionCode gitGitVersionCode()
        versionName getGitVersionName()
        signingConfig signingConfigs.debug
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true//使用vector图片
        ndk { abiFilters "armeabi-v7a" }//配置ndk
        packagingOptions { exclude "lib/arm64-v8a/librealm-jni.so" }//ReactNative配置
    }

源码RxFlux2,欢迎点赞指正!

上一篇 下一篇

猜你喜欢

热点阅读