aboutsummaryrefslogtreecommitdiffstats
path: root/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc/src/main/java/CrowdinDownloadPlugin.kt')
-rw-r--r--buildSrc/src/main/java/CrowdinDownloadPlugin.kt104
1 files changed, 50 insertions, 54 deletions
diff --git a/buildSrc/src/main/java/CrowdinDownloadPlugin.kt b/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
index af32975f..03a7859c 100644
--- a/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
+++ b/buildSrc/src/main/java/CrowdinDownloadPlugin.kt
@@ -14,63 +14,59 @@ import org.gradle.kotlin.dsl.register
class CrowdinDownloadPlugin : Plugin<Project> {
- override fun apply(project: Project) {
- with(project) {
- val extension = extensions.create<CrowdinExtension>("crowdin")
- afterEvaluate {
- val projectName = extension.projectName
- if (projectName.isEmpty()) {
- throw GradleException(
- """
+ override fun apply(project: Project) {
+ with(project) {
+ val extension = extensions.create<CrowdinExtension>("crowdin")
+ afterEvaluate {
+ val projectName = extension.projectName
+ if (projectName.isEmpty()) {
+ throw GradleException(
+ """
Applying `crowdin-plugin` requires a projectName to be configured via the "crowdin" extension.
- """.trimIndent()
- )
- }
- tasks.register<Download>("downloadCrowdin") {
- src("https://crowdin.com/backend/download/project/$projectName.zip")
- dest("$buildDir/translations.zip")
- overwrite(true)
- }
- tasks.register<Copy>("extractCrowdin") {
- setDependsOn(setOf("downloadCrowdin"))
- doFirst {
- File(buildDir, "translations").deleteRecursively()
- }
- from(zipTree("$buildDir/translations.zip"))
- into("$buildDir/translations")
- }
- tasks.register<Copy>("extractBaseStrings") {
- 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"))
- }
- }
- }
- tasks.register("crowdin") {
- setDependsOn(setOf("extractBaseStrings", "extractNonFreeStrings"))
- if (!extension.skipCleanup) {
- doLast {
- File("$buildDir/translations").deleteRecursively()
- File("$buildDir/nonFree-translations").deleteRecursively()
- File("$buildDir/translations.zip").delete()
- }
- }
+ """.trimIndent())
+ }
+ tasks.register<Download>("downloadCrowdin") {
+ src("https://crowdin.com/backend/download/project/$projectName.zip")
+ dest("$buildDir/translations.zip")
+ overwrite(true)
+ }
+ tasks.register<Copy>("extractCrowdin") {
+ setDependsOn(setOf("downloadCrowdin"))
+ doFirst { File(buildDir, "translations").deleteRecursively() }
+ from(zipTree("$buildDir/translations.zip"))
+ into("$buildDir/translations")
+ }
+ tasks.register<Copy>("extractBaseStrings") {
+ 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"))
}
+ }
+ }
+ tasks.register("crowdin") {
+ setDependsOn(setOf("extractBaseStrings", "extractNonFreeStrings"))
+ if (!extension.skipCleanup) {
+ doLast {
+ File("$buildDir/translations").deleteRecursively()
+ File("$buildDir/nonFree-translations").deleteRecursively()
+ File("$buildDir/translations.zip").delete()
}
+ }
}
+ }
}
+ }
}