Use try/catch with logging for version number
This commit is contained in:
parent
c8d66fa246
commit
1fe1e11e0e
|
@ -1,5 +1,3 @@
|
||||||
import org.apache.tools.ant.taskdefs.condition.Os
|
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
@ -96,12 +94,15 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
def getVersion() {
|
def getVersion() {
|
||||||
String result
|
def versionNumber = '0.0'
|
||||||
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
||||||
result = 'cmd /c git describe --always --long'.execute([], project.rootDir).text
|
try {
|
||||||
} else {
|
versionNumber = 'git describe --always --long'.execute([], project.rootDir).text
|
||||||
result = 'git describe --always --long'.execute([], project.rootDir).text
|
.trim()
|
||||||
|
.replaceAll(/(-0)?-[^-]+$/, "")
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error('Cannot find git, defaulting to dummy version number')
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.trim().replaceAll(/(-0)?-[^-]+$/, "")
|
return versionNumber
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue