Files
sailing-analytics/mobile/git.gradle
T

30 lines
599 B
Groovy

/**
* returns current git hash
*/
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine "git", "log", "-n", "1", "--format='%h'"
standardOutput = stdout
}
return stdout.toString().trim().replace("'", "")
}
/**
* set git hash into git.xml
*/
preBuild.doLast {
copy {
from ("../git.template.xml")
into ("res/values")
rename {
String fileName -> fileName.replace(".template", "")
}
filter {
String line -> line.replaceAll("#GITHASH#", getGitHash())
}
}
}