add commitId to debug build

pull/22/head
fengyuecanzhu 3 years ago
parent 9d523ef806
commit fd7ab4cf93
  1. 11
      app/build.gradle

@ -24,7 +24,7 @@ def releaseTime() {
return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+08:00")) return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+08:00"))
} }
def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim()) def commitId = 'git rev-parse --short HEAD'.execute().text.trim()
def getVersionCode() { def getVersionCode() {
def versionCodeFile = file('version_code.properties') def versionCodeFile = file('version_code.properties')
@ -122,14 +122,19 @@ android {
signingConfig signingConfigs.myConifg signingConfig signingConfigs.myConifg
} }
applicationIdSuffix ".debug" applicationIdSuffix ".debug"
versionNameSuffix "-" + gitCommits versionNameSuffix "-" + commitId
ndk { ndk {
abiFilters "arm64-v8a" abiFilters "arm64-v8a"
} }
} }
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
def buildType = variant.buildType.name
def fileName = "${name}v${defaultConfig.versionName}.apk"
if (buildType == "debug"){
fileName = "${name}v${defaultConfig.versionName}-${commitId}.apk"
}
variant.outputs.all { variant.outputs.all {
outputFileName = "${name}v${defaultConfig.versionName}.apk" outputFileName = fileName
} }
} }
} }

Loading…
Cancel
Save