[Gradle] Add configuration to store output files in release directory.

This commit is contained in:
Kuba Szczodrzyński 2021-03-31 10:51:59 +02:00
parent 2a3b1422ef
commit 1108f2eb71

View File

@ -31,15 +31,6 @@ android {
} }
buildTypes { 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 { debug {
minifyEnabled = false 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 { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')