本文共 800 字,大约阅读时间需要 2 分钟。
def gitVersionCode() { def cmd = 'git rev-list HEAD --first-parent --count' cmd.execute().text.trim().toInteger()}def gitVersionTag() { def cmd = 'git describe --tags' def version = cmd.execute().text.trim() def pattern = "-(\\d+)-g" def matcher = version =~ pattern if (matcher) { version = version.substring(0, matcher.start()) + "." + matcher[0][1] } else { version = version + ".0" } return version}
android {
compileSdkVersion 23buildToolsVersion "23.0.2"defaultConfig { applicationId "com.race604.example" minSdkVersion 15 targetSdkVersion 23 versionCode gitVersionCode() versionName gitVersionTag()}......
转载于:https://blog.51cto.com/4789781/2117490