gradle: sort extracted locales rather than generated XML

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2023-05-17 13:33:58 +02:00
parent f2d166a6a4
commit 37a892a2da

View File

@ -2,7 +2,7 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.android.build.gradle.tasks.GenerateLocaleConfigTask import com.android.build.gradle.tasks.ExtractSupportedLocalesTask
// Grotesque workaround for https://issuetracker.google.com/issues/279780940 // Grotesque workaround for https://issuetracker.google.com/issues/279780940
System.setProperty("com.android.tools.r8.disableApiModeling", "1") System.setProperty("com.android.tools.r8.disableApiModeling", "1")
@ -97,12 +97,10 @@ tasks.withType<KotlinCompile>().configureEach {
} }
// Grotesque workaround for https://issuetracker.google.com/issues/281825213 // Grotesque workaround for https://issuetracker.google.com/issues/281825213
tasks.withType<GenerateLocaleConfigTask>().configureEach { tasks.withType<ExtractSupportedLocalesTask>().configureEach {
doLast { doLast {
localeConfig.asFileTree.files.forEach { val file = localeList.asFile.get()
val lines = it.readLines() val lines = file.readLines()
val newLines = lines.subList(0, 2) + lines.subList(2, lines.size - 1).sorted() + lines.last() file.writeText((listOf(lines[0]) + lines.subList(1, lines.size).sorted()).joinToString(separator = "\n"))
it.writeText(newLines.joinToString(separator = "\n"))
}
} }
} }