Reputation: 13525
I am able to auto rename my apk files in gradle.build using
setProperty("archivesBaseName", "MyAppName-$versionName")
Is there a similar method to automatically append the proguard mapping folder name with the version number?
Currently, the folder defaults to
...\app\build\outputs\mapping\release or debug
I am wondering if it is possible to create the mapping folders to something like release-1.0.1
or debug-1.0.1
.
Upvotes: 3
Views: 421
Reputation: 21183
Following¹ will rename mapping.txt
to mapping-release-1.0.1.txt
in the same folder.
In the module build.gradle
file:
android {
// lots of gradle code
// The following portion renames the mapping.txt file.
applicationVariants.all { variant ->
if (variant.getBuildType().isMinifyEnabled()) {
variant.assemble.doLast {
variant.mappingFile.renameTo(file(
"${variant.mappingFile.parent}/mapping-${variant.name}-${variant.versionName}.txt"))
}
}
}
}
You may also use variant.versionCode
or other options in the file name.
Hope this helps.
Upvotes: 2
Reputation: 10971
I guess you can write a method that do the renaming by copying the files to directories based on the current version. something similar to the answer here: How to change the proguard mapping file name in gradle for Android project
Upvotes: 2