diff --git a/apache/build.gradle.kts b/apache/build.gradle.kts index 30af6ab21..e907ef617 100644 --- a/apache/build.gradle.kts +++ b/apache/build.gradle.kts @@ -1,3 +1,5 @@ +import org.gradle.kotlin.dsl.register + val androidSourceCompatibility: JavaVersion by rootProject.extra val androidTargetCompatibility: JavaVersion by rootProject.extra @@ -18,14 +20,14 @@ java { val lang3Src = "commons-lang/src/main/java/org/apache/commons/lang3" val localDir = "local/generated" -task("ClassUtilsX") { +tasks.register("ClassUtilsX") { from("$lang3Src/ClassUtils.java") into(localDir) filter { line: String -> line.replace("ClassUtils", "ClassUtilsX") } rename("(.+).java", "$1X.java") } -task("SerializationUtilsX") { +tasks.register("SerializationUtilsX") { from("$lang3Src/SerializationUtils.java") into(localDir) filter { line: String -> line.replace("SerializationUtils", "SerializationUtilsX") } diff --git a/app/build.gradle.kts b/app/build.gradle.kts index fbdd16e9e..51f793b41 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -134,6 +134,7 @@ dependencies { implementation(libs.androidx.preference) implementation(libs.androidx.recyclerview) implementation(libs.androidx.swiperefreshlayout) + implementation(libs.androidx.startup) implementation(libs.glide) implementation(libs.material) implementation(libs.gson) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index baccd0e0b..1b7032a06 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -28,7 +28,7 @@ android { namespace = "org.lsposed.lspd.core" buildFeatures { - androidResources = false + android.androidResources.enable = false buildConfig = true } diff --git a/dex2oat/build.gradle.kts b/dex2oat/build.gradle.kts index 2390988a9..7092988b1 100644 --- a/dex2oat/build.gradle.kts +++ b/dex2oat/build.gradle.kts @@ -25,7 +25,7 @@ android { namespace = "org.lsposed.dex2oat" buildFeatures { - androidResources = false + android.androidResources.enable = false buildConfig = false prefab = true prefabPublishing = true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index efef50b3e..4f1ba514b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -42,6 +42,8 @@ androidx-navigation-ui = { group = "androidx.navigation", name = "navigation-ui" androidx-preference = { module = "androidx.preference:preference", version = "1.2.1" } androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version = "1.4.0" } androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version = "1.2.0-beta01" } +#noinspection GradleDependency +androidx-startup = { module = "androidx.startup:startup-runtime", version = "1.1.1" } glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" } glide-compiler = { group = "com.github.bumptech.glide", name = "compiler", version.ref = "glide" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 1b33c55ba..8bdaf60c7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d4081da47..2a84e188b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 23d15a936..ef07e0162 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/magisk-loader/build.gradle.kts b/magisk-loader/build.gradle.kts index 6a50f6c4a..c6d069ae3 100644 --- a/magisk-loader/build.gradle.kts +++ b/magisk-loader/build.gradle.kts @@ -20,8 +20,16 @@ import org.apache.commons.codec.binary.Hex import org.apache.tools.ant.filters.FixCrLfFilter import org.apache.tools.ant.filters.ReplaceTokens +import org.gradle.api.Action +import org.gradle.api.provider.ProviderFactory +import org.gradle.api.tasks.Exec +import org.gradle.kotlin.dsl.register +import org.gradle.process.ExecResult +import org.gradle.process.ExecSpec +import org.gradle.process.ExecOperations import java.io.ByteArrayOutputStream import java.security.MessageDigest +import javax.inject.Inject plugins { alias(libs.plugins.agp.app) @@ -94,11 +102,19 @@ android { } namespace = "org.lsposed.lspd" } + abstract class Injected @Inject constructor(val magiskDir: String) { @get:Inject abstract val factory: ObjectFactory } +interface ExecOpsProvider { + @get:Inject + val execOperations: ExecOperations + @get:Inject + val providers: ProviderFactory +} + dependencies { implementation(projects.core) implementation(projects.hiddenapi.bridge) @@ -108,7 +124,7 @@ dependencies { compileOnly(projects.hiddenapi.stubs) } -val zipAll = task("zipAll") { +val zipAll = tasks.register("zipAll") { group = "LSPosed" } @@ -125,7 +141,7 @@ fun afterEval() = android.applicationVariants.forEach { variant -> val moduleId = "${flavorLowered}_$moduleBaseId" val zipFileName = "$moduleName-v$verName-$verCode-${flavorLowered}-$buildTypeLowered.zip" - val prepareMagiskFilesTask = task("prepareMagiskFiles$variantCapped") { + val prepareMagiskFilesTask = tasks.register("prepareMagiskFiles$variantCapped") { group = "LSPosed" dependsOn( "assemble$variantCapped", @@ -204,7 +220,7 @@ fun afterEval() = android.applicationVariants.forEach { variant -> } } - val zipTask = task("zip${variantCapped}") { + val zipTask = tasks.register("zip${variantCapped}") { group = "LSPosed" dependsOn(prepareMagiskFilesTask) archiveFileName = zipFileName @@ -212,16 +228,18 @@ fun afterEval() = android.applicationVariants.forEach { variant -> from(magiskDir) } - zipAll.dependsOn(zipTask) + zipAll.configure { + dependsOn(zipTask) + } val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath - val pushTask = task("push${variantCapped}") { + val pushTask = tasks.register("push${variantCapped}") { group = "LSPosed" dependsOn(zipTask) workingDir("${projectDir}/release") commandLine(adb, "push", zipFileName, "/data/local/tmp/") } - val flashMagiskTask = task("flashMagisk${variantCapped}") { + val flashMagiskTask = tasks.register("flashMagisk${variantCapped}") { group = "LSPosed" dependsOn(pushTask) commandLine( @@ -229,12 +247,12 @@ fun afterEval() = android.applicationVariants.forEach { variant -> "magisk --install-module /data/local/tmp/${zipFileName}" ) } - task("flashMagiskAndReboot${variantCapped}") { + tasks.register("flashMagiskAndReboot${variantCapped}") { group = "LSPosed" dependsOn(flashMagiskTask) commandLine(adb, "shell", "su", "-c", "/system/bin/svc", "power", "reboot") } - val flashKsuTask = task("flashKsu${variantCapped}") { + val flashKsuTask = tasks.register("flashKsu${variantCapped}") { group = "LSPosed" dependsOn(pushTask) commandLine( @@ -242,12 +260,12 @@ fun afterEval() = android.applicationVariants.forEach { variant -> "ksud module install /data/local/tmp/${zipFileName}" ) } - task("flashKsuAndReboot${variantCapped}") { + tasks.register("flashKsuAndReboot${variantCapped}") { group = "LSPosed" dependsOn(flashKsuTask) commandLine(adb, "shell", "su", "-c", "/system/bin/svc", "power", "reboot") } - val flashAPatchTask = task("flashAPatch${variantCapped}") { + val flashAPatchTask = tasks.register("flashAPatch${variantCapped}") { group = "LSPosed" dependsOn(pushTask) commandLine( @@ -255,7 +273,7 @@ fun afterEval() = android.applicationVariants.forEach { variant -> "apd module install /data/local/tmp/${zipFileName}" ) } - task("flashAPatchAndReboot${variantCapped}") { + tasks.register("flashAPatchAndReboot${variantCapped}") { group = "LSPosed" dependsOn(flashAPatchTask) commandLine(adb, "shell", "su", "-c", "/system/bin/svc", "power", "reboot") @@ -267,23 +285,24 @@ afterEvaluate { } val adb: String = androidComponents.sdkComponents.adb.get().asFile.absolutePath -val killLspd = task("killLspd") { +val killLspd = tasks.register("killLspd") { group = "LSPosed" commandLine(adb, "shell", "su", "-c", "killall", "lspd") isIgnoreExitValue = true } -val pushDaemon = task("pushDaemon") { +val pushDaemon = tasks.register("pushDaemon") { group = "LSPosed" dependsOn(":daemon:assembleDebug") workingDir(project(":daemon").layout.buildDirectory.dir("outputs/apk/debug")) commandLine(adb, "push", "daemon-debug.apk", "/data/local/tmp/daemon.apk") } -val pushDaemonNative = task("pushDaemonNative") { +val pushDaemonNative = tasks.register("pushDaemonNative") { group = "LSPosed" dependsOn(":daemon:assembleDebug") doFirst { + val execOpsProvider = objects.newInstance() val abi: String = ByteArrayOutputStream().use { outputStream -> - exec { + execOpsProvider.execOperations.exec { commandLine(adb, "shell", "getprop", "ro.product.cpu.abi") standardOutput = outputStream } @@ -293,10 +312,9 @@ val pushDaemonNative = task("pushDaemonNative") { } commandLine(adb, "push", "libdaemon.so", "/data/local/tmp/libdaemon.so") } -val reRunDaemon = task("reRunDaemon") { +val reRunDaemon = tasks.register("reRunDaemon") { group = "LSPosed" dependsOn(pushDaemon, pushDaemonNative, killLspd) - // tricky to pass a minus number to avoid the injection warning commandLine( adb, "shell", "ASH_STANDALONE=1", "su", "-mm", "-pc", "/data/adb/magisk/busybox sh /data/adb/modules/*_lsposed/service.sh --system-server-max-retry=-1&" @@ -304,18 +322,19 @@ val reRunDaemon = task("reRunDaemon") { isIgnoreExitValue = true } val tmpApk = "/data/local/tmp/manager.apk" -val pushApk = task("pushApk") { +val pushApk = tasks.register("pushApk") { group = "LSPosed" dependsOn(":app:assembleDebug") doFirst { - exec { + val execOpsProvider = objects.newInstance() + execOpsProvider.execOperations.exec { commandLine(adb, "shell", "su", "-c", "rm", "-f", tmpApk) } } workingDir(project(":app").layout.buildDirectory.dir("outputs/apk/debug")) commandLine(adb, "push", "app-debug.apk", tmpApk) } -val openApp = task("openApp") { +val openApp = tasks.register("openApp") { group = "LSPosed" commandLine( adb, "shell", @@ -323,11 +342,11 @@ val openApp = task("openApp") { "com.android.shell/.BugreportWarningActivity" ) } -task("reRunApp") { +tasks.register("reRunApp") { group = "LSPosed" dependsOn(pushApk) finalizedBy(reRunDaemon) } evaluationDependsOn(":app") -evaluationDependsOn(":daemon") +evaluationDependsOn(":daemon") \ No newline at end of file