set group for custom task (#1989)

This commit is contained in:
Ketal 2022-06-12 12:59:57 +08:00 committed by GitHub
parent 67545de17e
commit 0fffab2261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -221,6 +221,13 @@ fun Project.configureBaseExtension() {
} }
} }
fun Project.configureJavaExtension() {
extensions.findByType(JavaPluginExtension::class.java)?.run {
sourceCompatibility = androidSourceCompatibility
targetCompatibility = androidTargetCompatibility
}
}
subprojects { subprojects {
plugins.withId("com.android.application") { plugins.withId("com.android.application") {
configureBaseExtension() configureBaseExtension()
@ -228,4 +235,7 @@ subprojects {
plugins.withId("com.android.library") { plugins.withId("com.android.library") {
configureBaseExtension() configureBaseExtension()
} }
plugins.withId("org.gradle.java-library") {
configureJavaExtension()
}
} }

View File

@ -121,6 +121,7 @@ dependencies {
} }
val zipAll = task("zipAll") { val zipAll = task("zipAll") {
group = "LSPosed"
} }
@ -138,6 +139,7 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip" val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip"
val prepareMagiskFilesTask = task<Sync>("prepareMagiskFiles$variantCapped") { val prepareMagiskFilesTask = task<Sync>("prepareMagiskFiles$variantCapped") {
group = "LSPosed"
dependsOn( dependsOn(
"assemble$variantCapped", "assemble$variantCapped",
":app:package$buildTypeCapped", ":app:package$buildTypeCapped",
@ -229,6 +231,7 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
} }
val zipTask = task<Zip>("zip${variantCapped}") { val zipTask = task<Zip>("zip${variantCapped}") {
group = "LSPosed"
dependsOn(prepareMagiskFilesTask) dependsOn(prepareMagiskFilesTask)
archiveFileName.set(zipFileName) archiveFileName.set(zipFileName)
destinationDirectory.set(file("$projectDir/release")) destinationDirectory.set(file("$projectDir/release"))
@ -239,11 +242,13 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
val pushTask = task<Exec>("push${variantCapped}") { val pushTask = task<Exec>("push${variantCapped}") {
group = "LSPosed"
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<Exec>("flash${variantCapped}") { val flashTask = task<Exec>("flash${variantCapped}") {
group = "LSPosed"
dependsOn(pushTask) dependsOn(pushTask)
commandLine( commandLine(
adb, "shell", "su", "-c", adb, "shell", "su", "-c",
@ -251,6 +256,7 @@ fun afterEval() = android.applicationVariants.forEach { variant ->
) )
} }
task<Exec>("flashAndReboot${variantCapped}") { task<Exec>("flashAndReboot${variantCapped}") {
group = "LSPosed"
dependsOn(flashTask) dependsOn(flashTask)
commandLine(adb, "shell", "reboot") commandLine(adb, "shell", "reboot")
} }
@ -262,15 +268,18 @@ afterEvaluate {
val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath
val killLspd = task<Exec>("killLspd") { val killLspd = task<Exec>("killLspd") {
group = "LSPosed"
commandLine(adb, "shell", "su", "-c", "killall", "lspd") commandLine(adb, "shell", "su", "-c", "killall", "lspd")
isIgnoreExitValue = true isIgnoreExitValue = true
} }
val pushDaemon = task<Exec>("pushDaemon") { val pushDaemon = task<Exec>("pushDaemon") {
group = "LSPosed"
dependsOn(":daemon:assembleDebug") dependsOn(":daemon:assembleDebug")
workingDir("${project(":daemon").buildDir}/outputs/apk/debug") workingDir("${project(":daemon").buildDir}/outputs/apk/debug")
commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk") commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk")
} }
val pushDaemonNative = task<Exec>("pushDaemonNative") { val pushDaemonNative = task<Exec>("pushDaemonNative") {
group = "LSPosed"
dependsOn(":daemon:assembleDebug") dependsOn(":daemon:assembleDebug")
doFirst { doFirst {
val abi: String = ByteArrayOutputStream().use { outputStream -> val abi: String = ByteArrayOutputStream().use { outputStream ->
@ -285,6 +294,7 @@ val pushDaemonNative = task<Exec>("pushDaemonNative") {
commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so") commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so")
} }
val reRunDaemon = task<Exec>("reRunDaemon") { val reRunDaemon = task<Exec>("reRunDaemon") {
group = "LSPosed"
dependsOn(pushDaemon, pushDaemonNative, killLspd) dependsOn(pushDaemon, pushDaemonNative, killLspd)
// tricky to pass a minus number to avoid the injection warning // tricky to pass a minus number to avoid the injection warning
commandLine( commandLine(
@ -299,11 +309,13 @@ val reRunDaemon = task<Exec>("reRunDaemon") {
} }
val tmpApk = "/data/local/tmp/lsp.apk" val tmpApk = "/data/local/tmp/lsp.apk"
val pushApk = task<Exec>("pushApk") { val pushApk = task<Exec>("pushApk") {
group = "LSPosed"
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<Exec>("openApp") { val openApp = task<Exec>("openApp") {
group = "LSPosed"
commandLine( commandLine(
adb, adb,
"shell", "shell",
@ -317,6 +329,7 @@ val openApp = task<Exec>("openApp") {
) )
} }
task<Exec>("reRunApp") { task<Exec>("reRunApp") {
group = "LSPosed"
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