diff --git a/app/build.gradle b/app/build.gradle index 1e02f040..7d22ea41 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,15 +31,6 @@ android { } buildTypes { - applicationVariants.all { variant -> - variant.outputs.all { - if (variant.buildType.name == "release") { - outputFileName = "Edziennik_" + defaultConfig.versionName + ".apk" - } else { - outputFileName = "Edziennik_" + defaultConfig.versionName + "_debug.apk" - } - } - } debug { minifyEnabled = false } @@ -92,6 +83,30 @@ android { } } +tasks.whenTaskAdded { task -> + if (!task.name.endsWith("Release") && !task.name.endsWith("ReleaseWithR8")) + return + def renameTaskName = "rename${task.name.capitalize()}" + + def flavor = "" + if (task.name.startsWith("bundle")) + flavor = task.name.substring("bundle".length(), task.name.indexOf("Release")).uncapitalize() + if (task.name.startsWith("assemble")) + flavor = task.name.substring("assemble".length(), task.name.indexOf("Release")).uncapitalize() + if (task.name.startsWith("minify")) + flavor = task.name.substring("minify".length(), task.name.indexOf("Release")).uncapitalize() + + if (flavor != "") { + tasks.create(renameTaskName, Copy) { + from file("${projectDir}/${flavor}/release/"), file("${buildDir}/outputs/mapping/${flavor}Release/") + include "*.aab", "*.apk", "mapping.txt", "output-metadata.json" + destinationDir file("${projectDir}/release/") + rename ".+?\\.(.+)", "Edziennik_${android.defaultConfig.versionName}_${flavor}." + '$1' + } + task.finalizedBy(renameTaskName) + } +} + dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs')