Use modified branch names for APK

This commit is contained in:
maskara 2017-11-11 22:37:21 +05:30
parent c926437a0e
commit 68261c303f
2 changed files with 24 additions and 0 deletions

View file

@ -1,3 +1,4 @@
apply from: '../gitutils.gradle'
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'jacoco-android' apply plugin: 'jacoco-android'
apply from: 'quality.gradle' apply from: 'quality.gradle'
@ -66,6 +67,7 @@ android {
applicationId 'fr.free.nrw.commons' applicationId 'fr.free.nrw.commons'
versionCode 74 versionCode 74
versionName '2.5.0' versionName '2.5.0'
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
minSdkVersion project.minSdkVersion minSdkVersion project.minSdkVersion
targetSdkVersion project.targetSdkVersion targetSdkVersion project.targetSdkVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@ -79,6 +81,7 @@ android {
} }
debug { debug {
testCoverageEnabled true testCoverageEnabled true
versionNameSuffix "-debug-" + getBranchName() + "~" + getBuildVersion()
} }
} }

21
gitutils.gradle Normal file
View file

@ -0,0 +1,21 @@
ext.getBuildVersion = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
ext.getBranchName = { ->
try {
def stdOut = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
standardOutput = stdOut
}
return stdOut.toString().trim()
} catch (ignored) {
return null
}
}