Commit 84275b86 authored by Drahomír Karchňák's avatar Drahomír Karchňák

Gradle now renames apks after build.

parent 4ff2ab6c
......@@ -113,7 +113,7 @@ android {
defaultConfig {
targetSdkVersion 19
versionName getVersionNameFromGit()
versionName getVersionNameFromGit(false)
versionCode getVersionCodeFromGit()
applicationId = 'cz.nic.netmetr'
......@@ -178,6 +178,15 @@ android {
}
}
applicationVariants.all { variant ->
def extraInfo = variant.name.equals("dev")
variant.outputs.all {output ->
def file = output.outputFile;
outputFileName = file.name.replace(".apk", "-" + getVersionNameFromGit(extraInfo) + ".apk")
}
}
lintOptions {
abortOnError false
}
......@@ -239,15 +248,31 @@ def initResValues(buildType, IPv4Host, IPv6Host, IPv4CheckHost, IPv6CheckHost, C
}
}
def getVersionNameFromGit() {
def stdoutVersion = new ByteArrayOutputStream()
def getVersionNameFromGit(extraInfo) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always'
standardOutput = stdoutVersion
commandLine 'git', 'describe', '--abbrev=0', '--tags', '--always'
standardOutput = stdout
}
def tagVersion = stdout.toString().trim()
//add branch name and commit count from last tag
if(extraInfo) {
def branchName = getBranchNameFromGit()
//Get commit count
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', "${tagVersion}..HEAD", '--count'
standardOutput = stdout
}
def commitCount = stdout.toString().trim()
return "${tagVersion}-${branchName}(${commitCount})"
}
def branchName = getBranchNameFromGit()
return stdoutVersion.toString().trim() + '-' + branchName
return tagVersion
}
def getBranchNameFromGit() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment