From f9d19a957a78d6aadede6f4576b1310559c8ba88 Mon Sep 17 00:00:00 2001 From: Nullptr Date: Fri, 21 Apr 2023 16:19:49 +0800 Subject: [PATCH] manager: refactor to use AGP 8.0.0 (#414) --- .github/workflows/build-manager.yml | 178 ++++++++++-------- .gitignore | 3 +- manager/.gitignore | 18 +- manager/.idea/.gitignore | 3 - manager/.idea/.name | 1 - manager/.idea/compiler.xml | 6 - manager/.idea/gradle.xml | 20 -- .../inspectionProfiles/Project_Default.xml | 37 ---- manager/.idea/misc.xml | 10 - manager/.idea/vcs.xml | 6 - manager/app/build.gradle.kts | 115 ++++++----- manager/app/proguard-rules.pro | 30 +-- .../kernelsu/ExampleInstrumentedTest.kt | 24 --- manager/app/src/main/AndroidManifest.xml | 5 +- .../me/weishu/kernelsu/ui/MainActivity.kt | 36 ++-- .../me/weishu/kernelsu/ExampleUnitTest.kt | 17 -- manager/build.gradle.kts | 135 ++++++------- manager/gradle.properties | 24 +-- manager/gradle/libs.versions.toml | 55 ++++++ .../gradle/wrapper/gradle-wrapper.properties | 2 +- manager/settings.gradle.kts | 8 - 21 files changed, 312 insertions(+), 421 deletions(-) delete mode 100644 manager/.idea/.gitignore delete mode 100644 manager/.idea/.name delete mode 100644 manager/.idea/compiler.xml delete mode 100644 manager/.idea/gradle.xml delete mode 100644 manager/.idea/inspectionProfiles/Project_Default.xml delete mode 100644 manager/.idea/misc.xml delete mode 100644 manager/.idea/vcs.xml delete mode 100644 manager/app/src/androidTest/java/me/weishu/kernelsu/ExampleInstrumentedTest.kt delete mode 100644 manager/app/src/test/java/me/weishu/kernelsu/ExampleUnitTest.kt create mode 100644 manager/gradle/libs.versions.toml diff --git a/.github/workflows/build-manager.yml b/.github/workflows/build-manager.yml index 111d9f24..84474a19 100644 --- a/.github/workflows/build-manager.yml +++ b/.github/workflows/build-manager.yml @@ -1,16 +1,17 @@ name: Build Manager + on: push: branches: [ "main" ] - paths: + paths: - '.github/workflows/build-manager.yml' - 'manager/**' - 'userspace/ksud/**' pull_request: branches: [ "main" ] - paths: + paths: - 'manager/**' - workflow_call: + jobs: build-ksud: strategy: @@ -21,87 +22,104 @@ jobs: uses: ./.github/workflows/ksud.yml with: target: ${{ matrix.target }} + build-manager: needs: build-ksud runs-on: ubuntu-latest defaults: run: working-directory: ./manager + steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup need_upload - id: need_upload - run: | - if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then - echo "UPLOAD=true" >> $GITHUB_OUTPUT - else - echo "UPLOAD=false" >> $GITHUB_OUTPUT - fi - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'temurin' - cache: gradle - - uses: nttld/setup-ndk@v1 - with: - ndk-version: r25b - local-cache: true - - name: Extract keystore - if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }} - run: | - if [ ! -z "${{ secrets.KEYSTORE }}" ]; then - echo KEYSTORE_PASSWORD='${{ secrets.KEYSTORE_PASSWORD }}' >> sign.properties - echo KEY_ALIAS='${{ secrets.KEY_ALIAS }}' >> sign.properties - echo KEY_PASSWORD='${{ secrets.KEY_PASSWORD }}' >> sign.properties - echo KEYSTORE_FILE='../key.jks' >> sign.properties - echo ${{ secrets.KEYSTORE }} | base64 --decode > key.jks - fi - - name: Download arm64 ksud - uses: actions/download-artifact@v3 - with: - name: ksud-aarch64-linux-android - path: . - - name: Download x86_64 ksud - uses: actions/download-artifact@v3 - with: - name: ksud-x86_64-linux-android - path: . - - name: Copy ksud to app jniLibs - run: | - mkdir -p app/src/main/jniLibs/arm64-v8a - mkdir -p app/src/main/jniLibs/x86_64 - cp -f ../aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud.so - cp -f ../x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud.so - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew clean assembleRelease - - name: Upload build artifact - uses: actions/upload-artifact@v3 - with: - name: manager - path: manager/app/build/outputs/apk/release/*.apk - - name: Setup mutex for uploading - uses: ben-z/gh-action-mutex@v1.0-alpha-7 - if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' - - name: Upload to telegram - if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' - env: - CHAT_ID: ${{ secrets.CHAT_ID }} - CACHE_CHAT_ID: ${{ secrets.CACHE_CHAT_ID }} - BOT_TOKEN: ${{ secrets.BOT_TOKEN }} - MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }} - COMMIT_MESSAGE: ${{ github.event.head_commit.message }} - COMMIT_URL: ${{ github.event.head_commit.url }} - RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - TITLE: Manager - run: | - if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then - export VERSION=$(git rev-list --count HEAD) - APK=$(find ./app/build/outputs/apk/release -name "*.apk") - pip3 install python-telegram-bot - python3 $GITHUB_WORKSPACE/scripts/ksubot.py $APK - fi + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup need_upload + id: need_upload + run: | + if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then + echo "UPLOAD=true" >> $GITHUB_OUTPUT + else + echo "UPLOAD=false" >> $GITHUB_OUTPUT + fi + + - name: Write key + if: ${{ ( github.event_name != 'pull_request' && github.ref == 'refs/heads/main' ) || github.ref_type == 'tag' }} + run: | + if [ ! -z "${{ secrets.KEYSTORE }}" ]; then + echo KEYSTORE_PASSWORD='${{ secrets.KEYSTORE_PASSWORD }}' >> gradle.properties + echo KEY_ALIAS='${{ secrets.KEY_ALIAS }}' >> gradle.properties + echo KEY_PASSWORD='${{ secrets.KEY_PASSWORD }}' >> gradle.properties + echo KEYSTORE_FILE='../key.jks' >> gradle.properties + echo ${{ secrets.KEYSTORE }} | base64 --decode > key.jks + fi + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: "17" + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + with: + gradle-home-cache-cleanup: true + + - name: Download arm64 ksud + uses: actions/download-artifact@v3 + with: + name: ksud-aarch64-linux-android + path: . + + - name: Download x86_64 ksud + uses: actions/download-artifact@v3 + with: + name: ksud-x86_64-linux-android + path: . + + - name: Copy ksud to app jniLibs + run: | + mkdir -p app/src/main/jniLibs/arm64-v8a + mkdir -p app/src/main/jniLibs/x86_64 + cp -f ../aarch64-linux-android/release/ksud ../manager/app/src/main/jniLibs/arm64-v8a/libksud.so + cp -f ../x86_64-linux-android/release/ksud ../manager/app/src/main/jniLibs/x86_64/libksud.so + + - name: Build with Gradle + run: | + echo 'org.gradle.parallel=true' >> gradle.properties + echo 'org.gradle.vfs.watch=true' >> gradle.properties + echo 'org.gradle.jvmargs=-Xmx2048m' >> gradle.properties + echo 'android.native.buildOutput=verbose' >> gradle.properties + sed -i 's/org.gradle.configuration-cache=true//g' gradle.properties + ./gradlew clean assembleRelease + + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: manager + path: manager/app/build/outputs/apk/release/*.apk + + - name: Setup mutex for uploading + uses: ben-z/gh-action-mutex@v1.0-alpha-7 + if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' + + - name: Upload to telegram + if: github.event_name != 'pull_request' && steps.need_upload.outputs.UPLOAD == 'true' + env: + CHAT_ID: ${{ secrets.CHAT_ID }} + CACHE_CHAT_ID: ${{ secrets.CACHE_CHAT_ID }} + BOT_TOKEN: ${{ secrets.BOT_TOKEN }} + MESSAGE_THREAD_ID: ${{ secrets.MESSAGE_THREAD_ID }} + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + COMMIT_URL: ${{ github.event.head_commit.url }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + TITLE: Manager + run: | + if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then + export VERSION=$(git rev-list --count HEAD) + APK=$(find ./app/build/outputs/apk/release -name "*.apk") + pip3 install python-telegram-bot + python3 $GITHUB_WORKSPACE/scripts/ksubot.py $APK + fi diff --git a/.gitignore b/.gitignore index dbe9c82b..706fd07f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.vscode/ \ No newline at end of file +.idea +.vscode diff --git a/manager/.gitignore b/manager/.gitignore index c8a10379..dd42da43 100644 --- a/manager/.gitignore +++ b/manager/.gitignore @@ -1,17 +1,9 @@ *.iml .gradle -/local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml -.DS_Store -/build -/captures -.externalNativeBuild -.cxx local.properties -sign.properties +.idea +.DS_Store +build +captures +.cxx key.jks diff --git a/manager/.idea/.gitignore b/manager/.idea/.gitignore deleted file mode 100644 index 26d33521..00000000 --- a/manager/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/manager/.idea/.name b/manager/.idea/.name deleted file mode 100644 index 38c078d5..00000000 --- a/manager/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -KernelSU \ No newline at end of file diff --git a/manager/.idea/compiler.xml b/manager/.idea/compiler.xml deleted file mode 100644 index fb7f4a8a..00000000 --- a/manager/.idea/compiler.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/manager/.idea/gradle.xml b/manager/.idea/gradle.xml deleted file mode 100644 index a0de2a15..00000000 --- a/manager/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/manager/.idea/inspectionProfiles/Project_Default.xml b/manager/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index ed76bea3..00000000 --- a/manager/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - \ No newline at end of file diff --git a/manager/.idea/misc.xml b/manager/.idea/misc.xml deleted file mode 100644 index 360e6d41..00000000 --- a/manager/.idea/misc.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/manager/.idea/vcs.xml b/manager/.idea/vcs.xml deleted file mode 100644 index 6c0b8635..00000000 --- a/manager/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/manager/app/build.gradle.kts b/manager/app/build.gradle.kts index 8e8eaf01..e9f781f0 100644 --- a/manager/app/build.gradle.kts +++ b/manager/app/build.gradle.kts @@ -1,37 +1,51 @@ import com.android.build.gradle.internal.api.BaseVariantOutputImpl plugins { - id("com.android.application") - id("com.google.devtools.ksp") - kotlin("android") + alias(libs.plugins.agp.app) + alias(libs.plugins.kotlin) + alias(libs.plugins.ksp) + alias(libs.plugins.lsplugin.apksign) +} + +val managerVersionCode: Int by rootProject.extra +val managerVersionName: String by rootProject.extra + +apksign { + storeFileProperty = "KEYSTORE_FILE" + storePasswordProperty = "KEYSTORE_PASSWORD" + keyAliasProperty = "KEY_ALIAS" + keyPasswordProperty = "KEY_PASSWORD" } android { namespace = "me.weishu.kernelsu" - ndkVersion = "25.1.8937393" - - defaultConfig { - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - - ndk { - abiFilters += listOf("arm64-v8a", "x86_64") + buildTypes { + release { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") } } - lint { - checkReleaseBuilds = false - } - buildFeatures { + aidl = true + buildConfig = true compose = true } - composeOptions { - kotlinCompilerExtensionVersion = "1.3.2" + kotlinOptions { + jvmTarget = "17" } - packagingOptions { + composeOptions { + kotlinCompilerExtensionVersion = "1.4.3" + } + + packaging { + jniLibs { + useLegacyPackaging = true + } resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" } @@ -39,15 +53,14 @@ android { externalNativeBuild { cmake { - path(file("src/main/cpp/CMakeLists.txt")) - version = "3.18.1" + path("src/main/cpp/CMakeLists.txt") } } applicationVariants.all { outputs.forEach { val output = it as BaseVariantOutputImpl - output.outputFileName = "KernelSU_$versionName-${buildType.name}.apk" + output.outputFileName = "KernelSU_${managerVersionName}_${managerVersionCode}-$name.apk" } kotlin.sourceSets { @@ -59,40 +72,40 @@ android { } dependencies { - val accompanistVersion = "0.28.0" - val composeDestinationsVersion = "1.7.27-beta" - implementation(platform("androidx.compose:compose-bom:2023.04.00")) - debugImplementation("androidx.compose.ui:ui-test-manifest") - debugImplementation("androidx.compose.ui:ui-tooling") - implementation("androidx.activity:activity-compose:1.7.0") - implementation("androidx.compose.material:material:1.5.0-alpha01") - implementation("androidx.compose.material:material-icons-extended") - implementation("androidx.compose.material3:material3") - implementation("androidx.compose.ui:ui") - implementation("androidx.compose.ui:ui-tooling-preview") - implementation("androidx.core:core-ktx:1.9.0") - implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1") - implementation("androidx.navigation:navigation-compose:2.5.3") - implementation("com.google.accompanist:accompanist-drawablepainter:$accompanistVersion") - implementation("com.google.accompanist:accompanist-navigation-animation:$accompanistVersion") - implementation("com.google.accompanist:accompanist-systemuicontroller:$accompanistVersion") - implementation("io.github.raamcosta.compose-destinations:animations-core:$composeDestinationsVersion") + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.navigation.compose) - implementation("io.coil-kt:coil-compose:2.3.0") - implementation("me.zhanghai.android.appiconloader:appiconloader-coil:1.5.0") + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.compose.material.icons.extended) + implementation(libs.androidx.compose.material) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.ui.tooling.preview) - val libsuVersion = "5.0.5" - // change to official build(com.github.topjohnwu.libsu) when this pr is merged: - // https://github.com/topjohnwu/libsu/pull/151 - implementation("com.github.tiann.libsu:core:$libsuVersion") - implementation("com.github.tiann.libsu:service:$libsuVersion") - implementation("dev.rikka.rikkax.parcelablelist:parcelablelist:2.0.0") + debugImplementation(libs.androidx.compose.ui.test.manifest) + debugImplementation(libs.androidx.compose.ui.tooling) - implementation("com.github.alorma:compose-settings-ui-m3:0.22.0") + implementation(libs.androidx.lifecycle.runtime.compose) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.lifecycle.viewmodel.compose) - ksp("io.github.raamcosta.compose-destinations:ksp:$composeDestinationsVersion") + implementation(libs.com.google.accompanist.drawablepainter) + implementation(libs.com.google.accompanist.navigation.animation) + implementation(libs.com.google.accompanist.systemuicontroller) - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.4") - androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0") + implementation(libs.compose.destinations.animations.core) + ksp(libs.compose.destinations.ksp) + + implementation(libs.com.github.alorma.compose.settings.ui.m3) + + implementation(libs.com.github.topjohnwu.libsu.core) + implementation(libs.com.github.topjohnwu.libsu.service) + + implementation(libs.dev.rikka.rikkax.parcelablelist) + + implementation(libs.io.coil.kt.coil.compose) + + implementation(libs.kotlinx.coroutines.core) + + implementation(libs.me.zhanghai.android.appiconloader.coil) } diff --git a/manager/app/proguard-rules.pro b/manager/app/proguard-rules.pro index 481bb434..dcaf39ce 100644 --- a/manager/app/proguard-rules.pro +++ b/manager/app/proguard-rules.pro @@ -1,21 +1,9 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +-dontwarn org.bouncycastle.jsse.BCSSLParameters +-dontwarn org.bouncycastle.jsse.BCSSLSocket +-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider +-dontwarn org.conscrypt.Conscrypt$Version +-dontwarn org.conscrypt.Conscrypt +-dontwarn org.conscrypt.ConscryptHostnameVerifier +-dontwarn org.openjsse.javax.net.ssl.SSLParameters +-dontwarn org.openjsse.javax.net.ssl.SSLSocket +-dontwarn org.openjsse.net.ssl.OpenJSSE diff --git a/manager/app/src/androidTest/java/me/weishu/kernelsu/ExampleInstrumentedTest.kt b/manager/app/src/androidTest/java/me/weishu/kernelsu/ExampleInstrumentedTest.kt deleted file mode 100644 index 533af712..00000000 --- a/manager/app/src/androidTest/java/me/weishu/kernelsu/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package me.weishu.kernelsu - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("me.weishu.kernelsu", appContext.packageName) - } -} \ No newline at end of file diff --git a/manager/app/src/main/AndroidManifest.xml b/manager/app/src/main/AndroidManifest.xml index e41431b5..026ba015 100644 --- a/manager/app/src/main/AndroidManifest.xml +++ b/manager/app/src/main/AndroidManifest.xml @@ -6,14 +6,13 @@ android:name=".KernelSUApplication" android:allowBackup="true" android:dataExtractionRules="@xml/data_extraction_rules" - android:fullBackupContent="@xml/backup_rules" android:enableOnBackInvokedCallback="true" - android:extractNativeLibs="true" + android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.KernelSU" - tools:targetApi="31"> + tools:targetApi="33"> + val isCurrentDestOnBackStack by navController.isRouteOnBackStackAsState(destination.direction) NavigationBarItem( - selected = topDestination.route == destination.direction.route, + selected = isCurrentDestOnBackStack, onClick = { - val firstRoute = navController.backQueue.reversed().first { - it.destination.route in bottomBarRoutes - }.destination.route + if (isCurrentDestOnBackStack) { + navController.popBackStack(destination.direction, false) + } navController.navigate(destination.direction.route) { - popUpTo(navController.graph.findStartDestination().id) { - saveState = firstRoute != destination.direction.route + popUpTo(NavGraphs.root.route) { + saveState = true } launchSingleTop = true restoreState = true } }, icon = { - if (topDestination.route == destination.direction.route) { + if (topDestination?.route == destination.direction.route) { Icon(destination.iconSelected, stringResource(destination.label)) } else { Icon(destination.iconNotSelected, stringResource(destination.label)) diff --git a/manager/app/src/test/java/me/weishu/kernelsu/ExampleUnitTest.kt b/manager/app/src/test/java/me/weishu/kernelsu/ExampleUnitTest.kt deleted file mode 100644 index 1645b81c..00000000 --- a/manager/app/src/test/java/me/weishu/kernelsu/ExampleUnitTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package me.weishu.kernelsu - -import org.junit.Test - -import org.junit.Assert.* - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file diff --git a/manager/build.gradle.kts b/manager/build.gradle.kts index 2a91c86f..030ac9fd 100644 --- a/manager/build.gradle.kts +++ b/manager/build.gradle.kts @@ -1,33 +1,46 @@ -import com.android.build.api.dsl.ApplicationExtension -import com.android.build.gradle.BaseExtension -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.jetbrains.kotlin.konan.properties.Properties +import com.android.build.api.dsl.ApplicationDefaultConfig +import com.android.build.api.dsl.CommonExtension +import com.android.build.gradle.api.AndroidBasePlugin import java.io.ByteArrayOutputStream plugins { - id("com.android.application") apply false - id("com.android.library") apply false - kotlin("android") apply false + alias(libs.plugins.agp.app) apply false + alias(libs.plugins.agp.lib) apply false + alias(libs.plugins.kotlin) apply false + alias(libs.plugins.lsplugin.cmaker) } -buildscript { - repositories { - google() - mavenCentral() +cmaker { + default { + arguments.addAll( + arrayOf( + "-DANDROID_STL=c++_static", + ) + ) + val flags = arrayOf( + "-Wno-gnu-string-literal-operator-template", + "-Wno-c++2b-extensions", + ) + cFlags.addAll(flags) + cppFlags.addAll(flags) + abiFilters("arm64-v8a", "x86_64") } - dependencies { - classpath(kotlin("gradle-plugin", version = "1.7.20")) + buildTypes { + if (it.name == "release") { + arguments += "-DDEBUG_SYMBOLS_PATH=${buildDir.absolutePath}/symbols" + } } } -val androidMinSdk = 26 -val androidTargetSdk = 33 -val androidCompileSdk = 33 -val androidBuildToolsVersion = "33.0.1" -val androidSourceCompatibility = JavaVersion.VERSION_11 -val androidTargetCompatibility = JavaVersion.VERSION_11 -val managerVersionCode = getVersionCode() -val managerVersionName = getVersionName() +val androidMinSdkVersion = 26 +val androidTargetSdkVersion = 33 +val androidCompileSdkVersion = 33 +val androidBuildToolsVersion = "33.0.2" +val androidCompileNdkVersion = "25.2.9519653" +val androidSourceCompatibility = JavaVersion.VERSION_17 +val androidTargetCompatibility = JavaVersion.VERSION_17 +val managerVersionCode by extra(getVersionCode()) +val managerVersionName by extra(getVersionName()) tasks.register("clean") { delete(rootProject.buildDir) @@ -61,71 +74,31 @@ fun getVersionName(): String { return getGitDescribe() } -fun Project.configureBaseExtension() { - extensions.findByType()?.run { - compileSdkVersion(androidCompileSdk) - buildToolsVersion = androidBuildToolsVersion +subprojects { + plugins.withType(AndroidBasePlugin::class.java) { + extensions.configure(CommonExtension::class.java) { + compileSdk = androidCompileSdkVersion + ndkVersion = androidCompileNdkVersion + buildToolsVersion = androidBuildToolsVersion - defaultConfig { - minSdk = androidMinSdk - targetSdk = androidTargetSdk - versionCode = managerVersionCode - versionName = managerVersionName - - consumerProguardFiles("proguard-rules.pro") - } - - val signFile = rootProject.file("sign.properties") - val config = if (signFile.canRead()) { - val prop = Properties() - prop.load(signFile.inputStream()) - signingConfigs.create("config") { - storeFile = file(prop.getProperty("KEYSTORE_FILE")) - storePassword = prop.getProperty("KEYSTORE_PASSWORD") - keyAlias = prop.getProperty("KEY_ALIAS") - keyPassword = prop.getProperty("KEY_PASSWORD") - } - } else { - signingConfigs["debug"] - } - - buildTypes { - all { - signingConfig = config - } - - named("release") { - isMinifyEnabled = true - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } - - compileOptions { - sourceCompatibility = androidSourceCompatibility - targetCompatibility = androidTargetCompatibility - } - - extensions.findByType()?.run { - buildTypes { - named("release") { - isShrinkResources = true + defaultConfig { + minSdk = androidMinSdkVersion + if (this is ApplicationDefaultConfig) { + targetSdk = androidTargetSdkVersion + versionCode = managerVersionCode + versionName = managerVersionName } } - } - extensions.findByType()?.run { - kotlinOptions { - jvmTarget = "11" + lint { + abortOnError = true + checkReleaseBuilds = false + } + + compileOptions { + sourceCompatibility = androidSourceCompatibility + targetCompatibility = androidTargetCompatibility } } } } - -subprojects { - plugins.withId("com.android.application") { - configureBaseExtension() - } - plugins.withId("com.android.library") { - configureBaseExtension() - } -} diff --git a/manager/gradle.properties b/manager/gradle.properties index 3c5031eb..387da396 100644 --- a/manager/gradle.properties +++ b/manager/gradle.properties @@ -1,23 +1,3 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.experimental.enableNewResourceShrinker.preciseShrinking=true +android.enableAppCompileTimeRClass=true android.useAndroidX=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official -# Enables namespacing of each library's R class so that its R class includes only the -# resources declared in the library itself and none from the library's dependencies, -# thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file diff --git a/manager/gradle/libs.versions.toml b/manager/gradle/libs.versions.toml new file mode 100644 index 00000000..b7b6da15 --- /dev/null +++ b/manager/gradle/libs.versions.toml @@ -0,0 +1,55 @@ +[versions] +agp = "8.0.0" +kotlin = "1.8.10" +ksp = "1.8.10-1.0.9" +compose-bom = "2023.04.01" +lifecycle = "2.6.1" +accompanist = "0.30.0" +navigation = "2.5.3" +compose-destination = "1.9.40-beta" +libsu = "5.0.5" + +[plugins] +agp-app = { id = "com.android.application", version.ref = "agp" } +agp-lib = { id = "com.android.library", version.ref = "agp" } +kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +lsplugin-apksign = { id = "org.lsposed.lsplugin.apksign", version = "1.1" } +lsplugin-cmaker = { id = "org.lsposed.lsplugin.cmaker", version = "1.1" } + +[libraries] +androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version = "1.7.1" } +androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" } + +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" } +androidx-compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" } +androidx-compose-material = { group = "androidx.compose.material", name = "material" } +androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" } +androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } + +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle" } +androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycle" } +androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version = "lifecycle" } + +com-google-accompanist-drawablepainter = { group = "com.google.accompanist", name = "accompanist-drawablepainter", version.ref = "accompanist" } +com-google-accompanist-navigation-animation = { group = "com.google.accompanist", name = "accompanist-navigation-animation", version.ref = "accompanist" } +com-google-accompanist-systemuicontroller = { group = "com.google.accompanist", name = "accompanist-systemuicontroller", version.ref = "accompanist" } + +com-github-alorma-compose-settings-ui-m3 = { module = "com.github.alorma:compose-settings-ui-m3", version = "0.22.0" } + +com-github-topjohnwu-libsu-core = { group = "com.github.topjohnwu.libsu", name = "core", version.ref = "libsu" } +com-github-topjohnwu-libsu-service = { group = "com.github.topjohnwu.libsu", name = "service", version.ref = "libsu" } + +dev-rikka-rikkax-parcelablelist = { module = "dev.rikka.rikkax.parcelablelist:parcelablelist", version = "2.0.1" } + +io-coil-kt-coil-compose = { group = "io.coil-kt", name = "coil-compose", version = "2.3.0" } + +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version = "1.6.4" } + +me-zhanghai-android-appiconloader-coil = { group = "me.zhanghai.android.appiconloader", name = "appiconloader-coil", version = "1.5.0" } + +compose-destinations-animations-core = { group = "io.github.raamcosta.compose-destinations", name = "animations-core", version.ref = "compose-destination" } +compose-destinations-ksp = { group = "io.github.raamcosta.compose-destinations", name = "ksp", version.ref = "compose-destination" } diff --git a/manager/gradle/wrapper/gradle-wrapper.properties b/manager/gradle/wrapper/gradle-wrapper.properties index f26fd695..33aca6fd 100644 --- a/manager/gradle/wrapper/gradle-wrapper.properties +++ b/manager/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/manager/settings.gradle.kts b/manager/settings.gradle.kts index 7e938b11..b2c94096 100644 --- a/manager/settings.gradle.kts +++ b/manager/settings.gradle.kts @@ -6,14 +6,6 @@ pluginManagement { google() mavenCentral() } - plugins { - val agp = "7.4.2" - val kotlin = "1.7.20" - id("com.android.application") version agp - id("com.android.library") version agp - id("com.google.devtools.ksp") version "$kotlin-1.0.8" - kotlin("android") version kotlin - } } dependencyResolutionManagement {