From a65e492e3d360ddd810c4d57535bb10f885f6646 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 11 Aug 2026 00:15:56 +0000 Subject: [PATCH] Update build-logic - Prevent gradle from crashing when flags.prop does not exist - Fix ndk version [skip ci] --- app/build-logic/src/main/java/Plugin.kt | 12 ++++++++---- app/build-logic/src/main/java/Setup.kt | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/build-logic/src/main/java/Plugin.kt b/app/build-logic/src/main/java/Plugin.kt index 20ba42d4f..190d16ee2 100644 --- a/app/build-logic/src/main/java/Plugin.kt +++ b/app/build-logic/src/main/java/Plugin.kt @@ -10,6 +10,7 @@ import java.util.Random // CI builds are always reproducible val RAND_SEED = if (System.getenv("CI") != null) 42 else 0 lateinit var RANDOM: Random +val ABI_SUPPORT_LIST = listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64") private val props = Properties() @@ -21,10 +22,13 @@ object Config { fun contains(key: String) = get(key) != null - val version: String get() = get("version")!! + // Properties from config.prop and flags.prop, may be null + val version: String get() = get("version") ?: "null" + val abiList: List get() = get("abiList")?.split(",") ?: ABI_SUPPORT_LIST + + // Properties from gradle.properties, should always exist val versionCode: Int get() = get("magisk.versionCode")!!.toInt() val stubVersion: String get() = get("magisk.stubVersion")!! - val abiList: List get() = get("abiList")!!.split(",") } fun Project.rootFile(path: String): File { @@ -41,10 +45,10 @@ class MagiskPlugin : Plugin { props.clear() // Get gradle properties relevant to Magisk - props.putAll(properties.filter { (key, _) -> key.startsWith("magisk.") }) + props.putAll(providers.gradlePropertiesPrefixedBy("magisk.").get()) // Load config.prop - val configPath: String? by this + val configPath = findProperty("configPath") as String? val configFile = rootFile(configPath ?: "config.prop") if (configFile.exists()) { configFile.inputStream().use { diff --git a/app/build-logic/src/main/java/Setup.kt b/app/build-logic/src/main/java/Setup.kt index 251eb0c0c..b78a7449e 100644 --- a/app/build-logic/src/main/java/Setup.kt +++ b/app/build-logic/src/main/java/Setup.kt @@ -47,7 +47,7 @@ fun Project.setupCommon() { } buildToolsVersion = "37.0.0" ndkPath = "${androidComponents.sdkComponents.sdkDirectory.get().asFile}/ndk/magisk" - ndkVersion = "30.0.14904198" + ndkVersion = "30.0.15729638" defaultConfig.apply { minSdk = 23 @@ -282,7 +282,7 @@ fun Project.setupMainApk() { versionName = Config.version versionCode = Config.versionCode ndk { - abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64") + abiFilters += ABI_SUPPORT_LIST debugSymbolLevel = "FULL" } }