buildSrc: simplify CrowdinDownloadPlugin

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2021-03-20 12:40:01 +05:30
parent 7f757bed81
commit fbfe7dcb1e
No known key found for this signature in database
GPG Key ID: 366D7BBAD1031E80

View File

@ -36,28 +36,13 @@ class CrowdinDownloadPlugin : Plugin<Project> {
from(zipTree("$buildDir/translations.zip"))
into("$buildDir/translations")
}
tasks.register<Copy>("extractBaseStrings") {
tasks.register<Copy>("extractStrings") {
setDependsOn(setOf("extractCrowdin"))
from("$buildDir/translations/${project.name}/src/main/res")
into("${projectDir}/src/main/res")
}
tasks.register<Copy>("extractNonFreeStrings") {
setDependsOn(setOf("extractCrowdin"))
from("$buildDir/translations/") { exclude("app/") }
into("$buildDir/nonFree-translations")
doLast {
File("$buildDir/nonFree-translations")
.listFiles { file: File -> file.isDirectory }
?.forEach { file ->
val dest = File("${projectDir}/src/nonFree/values-${file.name}")
val src = File(file, "app/src/nonFree/res/values/strings.xml")
dest.mkdirs()
src.renameTo(File(dest, "strings.xml"))
}
}
from("$buildDir/translations/")
into("${projectDir}/src/")
}
tasks.register("crowdin") {
setDependsOn(setOf("extractBaseStrings", "extractNonFreeStrings"))
setDependsOn(setOf("extractStrings"))
if (!extension.skipCleanup) {
doLast {
File("$buildDir/translations").deleteRecursively()