From 774fda83ac276a635e3402034b1eedbd10be916f Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Tue, 9 Mar 2021 14:53:11 +0530 Subject: all: reformat with ktfmt Signed-off-by: Harsh Shandilya --- buildSrc/src/main/java/CrowdinDownloadPlugin.kt | 104 ++++++++++++------------ 1 file changed, 50 insertions(+), 54 deletions(-) (limited to 'buildSrc/src/main/java/CrowdinDownloadPlugin.kt') 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 { - override fun apply(project: Project) { - with(project) { - val extension = extensions.create("crowdin") - afterEvaluate { - val projectName = extension.projectName - if (projectName.isEmpty()) { - throw GradleException( - """ + override fun apply(project: Project) { + with(project) { + val extension = extensions.create("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("downloadCrowdin") { - src("https://crowdin.com/backend/download/project/$projectName.zip") - dest("$buildDir/translations.zip") - overwrite(true) - } - tasks.register("extractCrowdin") { - setDependsOn(setOf("downloadCrowdin")) - doFirst { - File(buildDir, "translations").deleteRecursively() - } - from(zipTree("$buildDir/translations.zip")) - into("$buildDir/translations") - } - tasks.register("extractBaseStrings") { - setDependsOn(setOf("extractCrowdin")) - from("$buildDir/translations/${project.name}/src/main/res") - into("${projectDir}/src/main/res") - } - tasks.register("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("downloadCrowdin") { + src("https://crowdin.com/backend/download/project/$projectName.zip") + dest("$buildDir/translations.zip") + overwrite(true) + } + tasks.register("extractCrowdin") { + setDependsOn(setOf("downloadCrowdin")) + doFirst { File(buildDir, "translations").deleteRecursively() } + from(zipTree("$buildDir/translations.zip")) + into("$buildDir/translations") + } + tasks.register("extractBaseStrings") { + setDependsOn(setOf("extractCrowdin")) + from("$buildDir/translations/${project.name}/src/main/res") + into("${projectDir}/src/main/res") + } + tasks.register("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() } + } } + } } + } } -- cgit v1.2.3