Generating git version string through resValue.
This commit is contained in:
@@ -4,38 +4,6 @@ plugins {
|
||||
|
||||
apply plugin: "androidx.navigation.safeargs"
|
||||
|
||||
//
|
||||
// Creates version.xml
|
||||
//
|
||||
task createVersionXML {
|
||||
doLast {
|
||||
def versionP = 'git describe --tags --long --dirty=-x --always --abbrev=8'
|
||||
.execute()
|
||||
versionP.waitFor()
|
||||
def version = versionP.text.trim()
|
||||
if ( versionP.exitValue() )
|
||||
throw new GradleException("Couldn't extract version. Git exited unexpectedly.")
|
||||
|
||||
def githashP = 'git rev-parse HEAD'.execute()
|
||||
githashP.waitFor()
|
||||
def githash = githashP.text.trim()
|
||||
if ( githashP.exitValue() )
|
||||
throw new GradleException("Couldn't extract git_hash. Git exited unexpectedly.")
|
||||
|
||||
def builddate = new Date()
|
||||
def versionFile = new FileWriter("app/src/main/res/values/version.xml")
|
||||
versionFile.println( '<?xml version="1.0" encoding="utf-8"?>' )
|
||||
versionFile.println( '<resources>' )
|
||||
versionFile.println( '<string name="git_version">' << version << '</string>' )
|
||||
versionFile.println( '<string name="git_hash">' << githash << '</string>' )
|
||||
versionFile.println( '<string name="build_date">' << builddate << '</string>' )
|
||||
versionFile.println( '<string name="version_code">0x00020001</string>' )
|
||||
versionFile.println( '</resources>' )
|
||||
versionFile.close()
|
||||
}
|
||||
}
|
||||
preBuild.dependsOn createVersionXML
|
||||
|
||||
//
|
||||
// Convert SVG images from art directory into PNG files.
|
||||
//
|
||||
@@ -51,7 +19,34 @@ preBuild.dependsOn createVersionXML
|
||||
//}
|
||||
//preBuild.dependsOn generateDrawablesFromArt
|
||||
|
||||
String gitVersion() {
|
||||
def versionP = 'git describe --tags --long --dirty=-x --always --abbrev=8'
|
||||
.execute()
|
||||
versionP.waitFor()
|
||||
if (versionP.exitValue())
|
||||
throw new GradleException("Couldn't extract version. Git exited unexpectedly.")
|
||||
return versionP.text.trim()
|
||||
}
|
||||
|
||||
String gitHash() {
|
||||
def githashP = 'git rev-parse HEAD'.execute()
|
||||
githashP.waitFor()
|
||||
if (githashP.exitValue())
|
||||
throw new GradleException("Couldn't extract git_hash. Git exited unexpectedly.")
|
||||
return githashP.text.trim()
|
||||
}
|
||||
|
||||
String buildDate() {
|
||||
def builddate = new Date()
|
||||
return builddate.toString()
|
||||
}
|
||||
|
||||
android {
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file('/Users/vahagnk/devel/banvor/keys/signing_key')
|
||||
}
|
||||
}
|
||||
compileSdk 31
|
||||
|
||||
defaultConfig {
|
||||
@@ -63,6 +58,10 @@ android {
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
resValue "bool", "debug_visible", "false"
|
||||
resValue "string", "git_version", gitVersion()
|
||||
resValue "string", "git_hash", gitHash()
|
||||
resValue "string", "build_date", buildDate()
|
||||
// resValue "string", "version_code", "0x00020001"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
||||
Reference in New Issue
Block a user