Upgrade gradle

This commit is contained in:
LoveSy
2023-02-20 14:55:27 +08:00
committed by John Wu
parent ae34659b26
commit 4ba365565f
19 changed files with 28 additions and 64 deletions

View File

@ -159,7 +159,7 @@ fun genStubManifest(srcDir: File, outDir: File): String {
fun List<String>.process() = asSequence()
.filter(::notJavaKeyword)
// Distinct by lower case to support case insensitive file systems
.distinctBy { it.toLowerCase(Locale.ROOT) }
.distinctBy { it.lowercase() }
val names = mutableListOf<String>()
names.addAll(c1)
@ -174,8 +174,7 @@ fun genStubManifest(srcDir: File, outDir: File): String {
cls.append(names.random(kRANDOM))
// Old Android does not support capitalized package names
// Check Android 7.0.0 PackageParser#buildClassName
cls[0] = cls[0].toLowerCase()
yield(cls.toString())
yield(cls.toString().replaceFirstChar { it.lowercase() })
}
}.distinct().iterator()

View File

@ -53,12 +53,12 @@ fun Project.setupCommon() {
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "11"
jvmTarget = "17"
}
}
}
@ -133,8 +133,8 @@ private fun Project.setupAppCommon() {
}
android.applicationVariants.all {
val projectName = project.name.toLowerCase(Locale.ROOT)
val variantCapped = name.capitalize(Locale.ROOT)
val projectName = project.name.lowercase()
val variantCapped = name.replaceFirstChar { it.uppercase() }
tasks.getByPath(":$projectName:package$variantCapped").doLast {
val apk = outputs.files.asFileTree.filter { it.name.endsWith(".apk") }.singleFile
val comment = "version=${Config.version}\nversionCode=${Config.versionCode}"
@ -191,7 +191,7 @@ fun Project.setupApp() {
}
android.applicationVariants.all {
val variantCapped = name.capitalize(Locale.ROOT)
val variantCapped = name.replaceFirstChar { it.uppercase() }
val stubTask = tasks.getByPath(":stub:package$variantCapped")
val stubApk = stubTask.outputs.files.asFileTree.filter {
@ -249,8 +249,8 @@ fun Project.setupStub() {
setupAppCommon()
android.applicationVariants.all {
val variantCapped = name.capitalize(Locale.ROOT)
val variantLowered = name.toLowerCase(Locale.ROOT)
val variantCapped = name.replaceFirstChar { it.uppercase() }
val variantLowered = name.lowercase()
val manifest = file("src/${variantLowered}/AndroidManifest.xml")
val outSrcDir = File(buildDir, "generated/source/obfuscate/${variantLowered}")
val templateDir = file("template")
@ -299,11 +299,12 @@ fun Project.setupStub() {
}
// Override optimizeReleaseResources task
tasks.whenTaskAdded {
val apk = File(buildDir, "intermediates/processed_res/" +
"release/out/resources-release.ap_")
val optRes = File(buildDir, "intermediates/optimized_processed_res/" +
"release/resources-release-optimize.ap_")
if (name == "optimizeReleaseResources") {
dependsOn("generateReleaseObfuscatedSources")
val apk = File(buildDir, "intermediates/processed_res/" +
"release/out/resources-release.ap_")
val optRes = File(buildDir, "intermediates/optimized_processed_res/" +
"release/resources-release-optimize.ap_")
doLast { apk.copyTo(optRes, true) }
}
}