Refine gradle script (#1495)

This commit is contained in:
LoveSy 2021-12-27 02:17:35 +08:00 committed by GitHub
parent 946ff240a8
commit de0579efde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 33 deletions

View File

@ -174,7 +174,7 @@ dependencies {
implementation("androidx.navigation:navigation-ui:$navVersion")
implementation("androidx.preference:preference:1.1.1")
implementation("androidx.recyclerview:recyclerview:1.2.1")
implementation("androidx.slidingpanelayout:slidingpanelayout:1.2.0-beta01")
implementation("androidx.slidingpanelayout:slidingpanelayout:1.2.0-rc01")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01")
implementation("com.github.bumptech.glide:glide:$glideVersion")
implementation("com.google.android.material:material:1.6.0-alpha01")

View File

@ -183,7 +183,7 @@ dependencies {
}
}
val zipAll = task("zipAll", Task::class) {
val zipAll = task("zipAll") {
}
@ -197,7 +197,7 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
val magiskDir = "$buildDir/magisk/$variantLowered"
task("generateApp${variantCapped}RFile", Jar::class) {
task<Jar>("generateApp${variantCapped}RFile") {
dependsOn(":app:process${buildTypeCapped}Resources")
doLast {
val rFile = JarFile(
@ -241,25 +241,24 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
sign?.keyPassword,
sign?.keyAlias
)
PrintStream(outSrc).apply {
println("package org.lsposed.lspd.util;")
println("public final class SignInfo {")
print("public static final byte[] CERTIFICATE = {")
val bytes = certificateInfo.certificate.encoded
print(bytes.joinToString(",") { it.toString() })
println("};")
println("}")
}
PrintStream(outSrc).print(
"""
|package org.lsposed.lspd.util;
|public final class SignInfo {
| public static final byte[] CERTIFICATE = {${
certificateInfo.certificate.encoded.joinToString(",")
}};
|}""".trimMargin()
)
}
}
variant.registerJavaGeneratingTask(signInfoTask, arrayListOf(outSrcDir))
variant.registerJavaGeneratingTask(signInfoTask, outSrcDir)
val moduleId = "${flavorLowered}_$moduleBaseId"
val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip"
val prepareMagiskFilesTask = task("prepareMagiskFiles$variantCapped", Sync::class) {
dependsOn("assemble$variantCapped")
dependsOn(":app:assemble$buildTypeCapped")
val prepareMagiskFilesTask = task<Sync>("prepareMagiskFiles$variantCapped") {
dependsOn("assemble$variantCapped", ":app:assemble$buildTypeCapped")
into(magiskDir)
from("${rootProject.projectDir}/README.md")
from("$projectDir/magisk_module") {
@ -327,7 +326,7 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
}
}
val zipTask = task("zip${variantCapped}", Zip::class) {
val zipTask = task<Zip>("zip${variantCapped}") {
dependsOn(prepareMagiskFilesTask)
archiveFileName.set(zipFileName)
destinationDirectory.set(file("$projectDir/release"))
@ -337,19 +336,19 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
zipAll.dependsOn(zipTask)
val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
val pushTask = task("push${variantCapped}", Exec::class) {
val pushTask = task<Exec>("push${variantCapped}") {
dependsOn(zipTask)
workingDir("${projectDir}/release")
commandLine(adb, "push", zipFileName, "/data/local/tmp/")
}
val flashTask = task("flash${variantCapped}", Exec::class) {
val flashTask = task<Exec>("flash${variantCapped}") {
dependsOn(pushTask)
commandLine(
adb, "shell", "su", "-c",
"magisk --install-module /data/local/tmp/${zipFileName}"
)
}
task("flashAndReboot${variantCapped}", Exec::class) {
task<Exec>("flashAndReboot${variantCapped}") {
dependsOn(flashTask)
commandLine(adb, "shell", "reboot")
}
@ -360,16 +359,16 @@ afterEvaluate {
}
val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
val killLspd = task("killLspd", Exec::class) {
val killLspd = task<Exec>("killLspd") {
commandLine(adb, "shell", "su", "-c", "killall", "lspd")
isIgnoreExitValue = true
}
val pushLspd = task("pushLspd", Exec::class) {
val pushLspd = task<Exec>("pushLspd") {
dependsOn("mergeDexRiruDebug")
workingDir("$buildDir/intermediates/dex/RiruDebug/mergeDexRiruDebug")
commandLine(adb, "push", "classes.dex", "/data/local/tmp/lspd.dex")
}
val pushLspdNative = task("pushLspdNative", Exec::class) {
val pushLspdNative = task<Exec>("pushLspdNative") {
dependsOn("mergeRiruDebugNativeLibs")
doFirst {
val abi: String = ByteArrayOutputStream().use { outputStream ->
@ -383,27 +382,31 @@ val pushLspdNative = task("pushLspdNative", Exec::class) {
}
commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so")
}
val reRunLspd = task("reRunLspd", Exec::class) {
dependsOn(pushLspd)
dependsOn(pushLspdNative)
dependsOn(killLspd)
val reRunLspd = task<Exec>("reRunLspd") {
dependsOn(pushLspd, pushLspdNative, killLspd)
commandLine(adb, "shell", "su", "-c", "sh /data/adb/modules/*_lsposed/service.sh&")
isIgnoreExitValue = true
}
val tmpApk = "/data/local/tmp/lsp.apk"
val pushApk = task("pushApk", Exec::class) {
val pushApk = task<Exec>("pushApk") {
dependsOn(":app:assembleDebug")
workingDir("${project(":app").buildDir}/outputs/apk/debug")
commandLine(adb, "push", "app-debug.apk", tmpApk)
}
val openApp = task("openApp", Exec::class) {
val openApp = task<Exec>("openApp") {
commandLine(
adb, "shell", "am start -a android.intent.action.MAIN " +
"-c org.lsposed.manager.LAUNCH_MANAGER " +
"com.android.shell/.BugreportWarningActivity"
adb,
"shell",
"am",
"start",
"-a",
"android.intent.action.MAIN",
"-c",
"org.lsposed.manager.LAUNCH_MANAGER",
"com.android.shell/.BugreportWarningActivity"
)
}
task("reRunApp", Exec::class) {
task<Exec>("reRunApp") {
dependsOn(pushApk)
commandLine(adb, "shell", "su", "-c", "mv -f $tmpApk /data/adb/lspd/manager.apk")
isIgnoreExitValue = true