I'm trying to use the method described in this other SO question to generate the version info for an Android application:
Automatically versioning Android project from git describe with Android Studio/Gradle
The method depends on calling the git
command from the gradle script. One requirement seems to be that git
be in the path environment variable.
Is there a way to obtain this path from AndroidStudio's git settings?
(Version Control > Git: Path to Git Executable) I'd prefer if I didn't have to set up the environment variable and avoid hardcoding the directory where git
is installed.
For reference, here's the method to obtain the version name from the linked question:
def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--dirty'
standardOutput = stdout
}
return stdout.toString().trim()
}
catch (ignored) {
return null;
}
}