AndroidManifest.xml versionName is also automatically updated on build
This commit is contained in:
parent
2547eda8bd
commit
6f1bb5820a
2 changed files with 10 additions and 8 deletions
|
|
@ -38,7 +38,7 @@ tasks.register('writeDictionaryProperties') {
|
|||
|
||||
tasks.register('updateManifest') {
|
||||
doLast {
|
||||
updateManifestVersion(getVersionCode())
|
||||
updateManifestVersion(getVersionCode(), getVersionName())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,11 +61,13 @@ ext.getReleaseVersion = { ->
|
|||
return "${generateVersionName()} (${getCurrentGitHash()})"
|
||||
}
|
||||
|
||||
ext.updateManifestVersion = { currentVersion ->
|
||||
def manifestFile = file("src/main/AndroidManifest.xml")
|
||||
def pattern = ~"versionCode=\"([^\"]+)\""
|
||||
def matcher = pattern.matcher(manifestFile.getText())
|
||||
matcher.find()
|
||||
def newManifest = matcher.replaceAll("versionCode=\"" + (currentVersion + 1) + "\"")
|
||||
manifestFile.write(newManifest)
|
||||
ext.updateManifestVersion = { versionCode, versionName ->
|
||||
def manifestFile = file("src/main/AndroidManifest.xml")
|
||||
|
||||
def newManifest = manifestFile
|
||||
.getText()
|
||||
.replaceFirst(~"versionCode=\"([^\"]+)\"", "versionCode=\"" + versionCode + "\"")
|
||||
.replaceFirst(~"versionName=\"([^\"]+)\"", "versionName=\"" + versionName + "\"")
|
||||
|
||||
manifestFile.write(newManifest)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue