验证中...
本周日【珠海源创会】一起聊聊:PingCAP分布式事务、支付宝移动端实践、GSBN技术框架选型,点此报名占座
语言: Groovy
最后更新于 2017-07-27 18:53
build.gradle
原始数据 复制代码
def releaseTime() {
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
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
}
//自定义apk安装包名
applicationVariants.all { variant ->
variant.mergedFlavor.versionCode = gitVersionCode()
variant.mergedFlavor.versionName = gitVersionTag()
variant.outputs.each { output ->
output.outputFile = new File(
output.outputFile.parent + "/${variant.buildType.name}",
"HelloWord-${variant.buildType.name}-v${variant.versionName}-${variant.productFlavors[0].name}-${releaseTime()}.apk".toLowerCase())
}
}

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助

12_float_left_people 12_float_left_close