I saw that a lot of people is using git tag to read the version during build and then assemble however i would like to do the opposite.
I already have my version name and code dynamically created in my build.gradle and i want to tag the current git commit every time i do an assemble (which changes the version name) with the version name PLUS the current variant name (so i need it to be variant independent). What i am not able to do is read the current version name from the variant i am building, so, something like:
task gitTag(type: Exec) {
exec {
currentVersionName = android.variant.name
commandLine 'git tag -a ' + currentVersionName
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'assemble') {
task.dependsOn = gitTag
}
}
On top of this, since it appears no one is doing this, is this a bad approach?