Delete empty values directories in Crowdin cleanup (#1656)

This commit is contained in:
Harsh Shandilya 2022-01-10 02:00:53 +05:30 committed by GitHub
parent cfceb38ee7
commit 0def9a04f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,10 +84,10 @@ class CrowdinDownloadPlugin : Plugin<Project> {
doLast { doLast {
val sourceSets = arrayOf("main", "nonFree") val sourceSets = arrayOf("main", "nonFree")
for (sourceSet in sourceSets) { for (sourceSet in sourceSets) {
val stringFiles = val fileTreeWalk = projectDir.resolve("src/$sourceSet").walkTopDown()
File("${projectDir}/src/$sourceSet").walkTopDown().filter { val valuesDirectories =
it.name == "strings.xml" fileTreeWalk.filter { it.isDirectory }.filter { it.name.startsWith("values") }
} val stringFiles = fileTreeWalk.filter { it.name == "strings.xml" }
val sourceFile = val sourceFile =
stringFiles.firstOrNull { it.path.endsWith("values/strings.xml") } stringFiles.firstOrNull { it.path.endsWith("values/strings.xml") }
?: throw GradleException("No root strings.xml found in '$sourceSet' sourceSet") ?: throw GradleException("No root strings.xml found in '$sourceSet' sourceSet")
@ -103,6 +103,11 @@ class CrowdinDownloadPlugin : Plugin<Project> {
} }
} }
} }
valuesDirectories.forEach { dir ->
if (dir.listFiles().isNullOrEmpty()) {
dir.delete()
}
}
} }
} }
} }