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'
|
||||
|
||||
android {
|
||||
|
@ -96,12 +94,15 @@ dependencies {
|
|||
}
|
||||
|
||||
def getVersion() {
|
||||
String result
|
||||
if(Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
result = 'cmd /c git describe --always --long'.execute([], project.rootDir).text
|
||||
} else {
|
||||
result = 'git describe --always --long'.execute([], project.rootDir).text
|
||||
def versionNumber = '0.0'
|
||||
|
||||
try {
|
||||
versionNumber = '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