Refine gradle script (#1495)
This commit is contained in:
parent
946ff240a8
commit
de0579efde
|
|
@ -174,7 +174,7 @@ dependencies {
|
||||||
implementation("androidx.navigation:navigation-ui:$navVersion")
|
implementation("androidx.navigation:navigation-ui:$navVersion")
|
||||||
implementation("androidx.preference:preference:1.1.1")
|
implementation("androidx.preference:preference:1.1.1")
|
||||||
implementation("androidx.recyclerview:recyclerview:1.2.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("androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01")
|
||||||
implementation("com.github.bumptech.glide:glide:$glideVersion")
|
implementation("com.github.bumptech.glide:glide:$glideVersion")
|
||||||
implementation("com.google.android.material:material:1.6.0-alpha01")
|
implementation("com.google.android.material:material:1.6.0-alpha01")
|
||||||
|
|
|
||||||
|
|
@ -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"
|
val magiskDir = "$buildDir/magisk/$variantLowered"
|
||||||
|
|
||||||
task("generateApp${variantCapped}RFile", Jar::class) {
|
task<Jar>("generateApp${variantCapped}RFile") {
|
||||||
dependsOn(":app:process${buildTypeCapped}Resources")
|
dependsOn(":app:process${buildTypeCapped}Resources")
|
||||||
doLast {
|
doLast {
|
||||||
val rFile = JarFile(
|
val rFile = JarFile(
|
||||||
|
|
@ -241,25 +241,24 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
|
||||||
sign?.keyPassword,
|
sign?.keyPassword,
|
||||||
sign?.keyAlias
|
sign?.keyAlias
|
||||||
)
|
)
|
||||||
PrintStream(outSrc).apply {
|
PrintStream(outSrc).print(
|
||||||
println("package org.lsposed.lspd.util;")
|
"""
|
||||||
println("public final class SignInfo {")
|
|package org.lsposed.lspd.util;
|
||||||
print("public static final byte[] CERTIFICATE = {")
|
|public final class SignInfo {
|
||||||
val bytes = certificateInfo.certificate.encoded
|
| public static final byte[] CERTIFICATE = {${
|
||||||
print(bytes.joinToString(",") { it.toString() })
|
certificateInfo.certificate.encoded.joinToString(",")
|
||||||
println("};")
|
}};
|
||||||
println("}")
|
|}""".trimMargin()
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
variant.registerJavaGeneratingTask(signInfoTask, arrayListOf(outSrcDir))
|
variant.registerJavaGeneratingTask(signInfoTask, outSrcDir)
|
||||||
|
|
||||||
val moduleId = "${flavorLowered}_$moduleBaseId"
|
val moduleId = "${flavorLowered}_$moduleBaseId"
|
||||||
val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip"
|
val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip"
|
||||||
|
|
||||||
val prepareMagiskFilesTask = task("prepareMagiskFiles$variantCapped", Sync::class) {
|
val prepareMagiskFilesTask = task<Sync>("prepareMagiskFiles$variantCapped") {
|
||||||
dependsOn("assemble$variantCapped")
|
dependsOn("assemble$variantCapped", ":app:assemble$buildTypeCapped")
|
||||||
dependsOn(":app:assemble$buildTypeCapped")
|
|
||||||
into(magiskDir)
|
into(magiskDir)
|
||||||
from("${rootProject.projectDir}/README.md")
|
from("${rootProject.projectDir}/README.md")
|
||||||
from("$projectDir/magisk_module") {
|
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)
|
dependsOn(prepareMagiskFilesTask)
|
||||||
archiveFileName.set(zipFileName)
|
archiveFileName.set(zipFileName)
|
||||||
destinationDirectory.set(file("$projectDir/release"))
|
destinationDirectory.set(file("$projectDir/release"))
|
||||||
|
|
@ -337,19 +336,19 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
|
||||||
zipAll.dependsOn(zipTask)
|
zipAll.dependsOn(zipTask)
|
||||||
|
|
||||||
val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
|
val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
|
||||||
val pushTask = task("push${variantCapped}", Exec::class) {
|
val pushTask = task<Exec>("push${variantCapped}") {
|
||||||
dependsOn(zipTask)
|
dependsOn(zipTask)
|
||||||
workingDir("${projectDir}/release")
|
workingDir("${projectDir}/release")
|
||||||
commandLine(adb, "push", zipFileName, "/data/local/tmp/")
|
commandLine(adb, "push", zipFileName, "/data/local/tmp/")
|
||||||
}
|
}
|
||||||
val flashTask = task("flash${variantCapped}", Exec::class) {
|
val flashTask = task<Exec>("flash${variantCapped}") {
|
||||||
dependsOn(pushTask)
|
dependsOn(pushTask)
|
||||||
commandLine(
|
commandLine(
|
||||||
adb, "shell", "su", "-c",
|
adb, "shell", "su", "-c",
|
||||||
"magisk --install-module /data/local/tmp/${zipFileName}"
|
"magisk --install-module /data/local/tmp/${zipFileName}"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
task("flashAndReboot${variantCapped}", Exec::class) {
|
task<Exec>("flashAndReboot${variantCapped}") {
|
||||||
dependsOn(flashTask)
|
dependsOn(flashTask)
|
||||||
commandLine(adb, "shell", "reboot")
|
commandLine(adb, "shell", "reboot")
|
||||||
}
|
}
|
||||||
|
|
@ -360,16 +359,16 @@ afterEvaluate {
|
||||||
}
|
}
|
||||||
|
|
||||||
val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
|
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")
|
commandLine(adb, "shell", "su", "-c", "killall", "lspd")
|
||||||
isIgnoreExitValue = true
|
isIgnoreExitValue = true
|
||||||
}
|
}
|
||||||
val pushLspd = task("pushLspd", Exec::class) {
|
val pushLspd = task<Exec>("pushLspd") {
|
||||||
dependsOn("mergeDexRiruDebug")
|
dependsOn("mergeDexRiruDebug")
|
||||||
workingDir("$buildDir/intermediates/dex/RiruDebug/mergeDexRiruDebug")
|
workingDir("$buildDir/intermediates/dex/RiruDebug/mergeDexRiruDebug")
|
||||||
commandLine(adb, "push", "classes.dex", "/data/local/tmp/lspd.dex")
|
commandLine(adb, "push", "classes.dex", "/data/local/tmp/lspd.dex")
|
||||||
}
|
}
|
||||||
val pushLspdNative = task("pushLspdNative", Exec::class) {
|
val pushLspdNative = task<Exec>("pushLspdNative") {
|
||||||
dependsOn("mergeRiruDebugNativeLibs")
|
dependsOn("mergeRiruDebugNativeLibs")
|
||||||
doFirst {
|
doFirst {
|
||||||
val abi: String = ByteArrayOutputStream().use { outputStream ->
|
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")
|
commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so")
|
||||||
}
|
}
|
||||||
val reRunLspd = task("reRunLspd", Exec::class) {
|
val reRunLspd = task<Exec>("reRunLspd") {
|
||||||
dependsOn(pushLspd)
|
dependsOn(pushLspd, pushLspdNative, killLspd)
|
||||||
dependsOn(pushLspdNative)
|
|
||||||
dependsOn(killLspd)
|
|
||||||
commandLine(adb, "shell", "su", "-c", "sh /data/adb/modules/*_lsposed/service.sh&")
|
commandLine(adb, "shell", "su", "-c", "sh /data/adb/modules/*_lsposed/service.sh&")
|
||||||
isIgnoreExitValue = true
|
isIgnoreExitValue = true
|
||||||
}
|
}
|
||||||
val tmpApk = "/data/local/tmp/lsp.apk"
|
val tmpApk = "/data/local/tmp/lsp.apk"
|
||||||
val pushApk = task("pushApk", Exec::class) {
|
val pushApk = task<Exec>("pushApk") {
|
||||||
dependsOn(":app:assembleDebug")
|
dependsOn(":app:assembleDebug")
|
||||||
workingDir("${project(":app").buildDir}/outputs/apk/debug")
|
workingDir("${project(":app").buildDir}/outputs/apk/debug")
|
||||||
commandLine(adb, "push", "app-debug.apk", tmpApk)
|
commandLine(adb, "push", "app-debug.apk", tmpApk)
|
||||||
}
|
}
|
||||||
val openApp = task("openApp", Exec::class) {
|
val openApp = task<Exec>("openApp") {
|
||||||
commandLine(
|
commandLine(
|
||||||
adb, "shell", "am start -a android.intent.action.MAIN " +
|
adb,
|
||||||
"-c org.lsposed.manager.LAUNCH_MANAGER " +
|
"shell",
|
||||||
"com.android.shell/.BugreportWarningActivity"
|
"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)
|
dependsOn(pushApk)
|
||||||
commandLine(adb, "shell", "su", "-c", "mv -f $tmpApk /data/adb/lspd/manager.apk")
|
commandLine(adb, "shell", "su", "-c", "mv -f $tmpApk /data/adb/lspd/manager.apk")
|
||||||
isIgnoreExitValue = true
|
isIgnoreExitValue = true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue