From 7922f65243beb872b4649b97769285e33beed0d2 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 4 Jul 2020 06:53:31 -0700 Subject: [PATCH] Welcome Gradle Kotlin DSL --- app/build.gradle | 145 ------------------------ app/build.gradle.kts | 153 ++++++++++++++++++++++++++ app/shared/build.gradle | 12 -- app/shared/build.gradle.kts | 14 +++ app/signing/build.gradle | 39 ------- app/signing/build.gradle.kts | 35 ++++++ build.gradle | 128 --------------------- build.gradle.kts | 125 +++++++++++++++++++++ buildSrc/.gitignore | 1 + buildSrc/build.gradle.kts | 15 +++ buildSrc/src/main/java/BuildSource.kt | 29 +++++ native/build.gradle | 22 ---- native/build.gradle.kts | 24 ++++ settings.gradle | 1 - settings.gradle.kts | 1 + stub/build.gradle | 24 ---- stub/build.gradle.kts | 28 +++++ 17 files changed, 425 insertions(+), 371 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 app/shared/build.gradle create mode 100644 app/shared/build.gradle.kts delete mode 100644 app/signing/build.gradle create mode 100644 app/signing/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 buildSrc/.gitignore create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/java/BuildSource.kt delete mode 100644 native/build.gradle create mode 100644 native/build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts delete mode 100644 stub/build.gradle create mode 100644 stub/build.gradle.kts diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index afa15634d..000000000 --- a/app/build.gradle +++ /dev/null @@ -1,145 +0,0 @@ -plugins { - id("com.android.application") - id("kotlin-android") - id("kotlin-android-extensions") - id("kotlin-kapt") - id("androidx.navigation.safeargs.kotlin") -} - -kapt { - correctErrorTypes = true - useBuildCache = true - mapDiagnosticLocations = true - javacOptions { - option("-Xmaxerrs", 1000) - } -} - -android { - defaultConfig { - applicationId 'com.topjohnwu.magisk' - vectorDrawables.useSupportLibrary = true - multiDexEnabled true - versionName props['appVersion'] - versionCode props['appVersionCode'] as Integer - buildConfigField 'int', 'LATEST_MAGISK', props['versionCode'] ?: 'Integer.MAX_VALUE' - - javaCompileOptions { - annotationProcessorOptions { - arguments = ["room.incremental": "true"] - } - } - } - - buildTypes { - release { - minifyEnabled true - shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), - 'proguard-rules.pro' - } - } - - buildFeatures { - dataBinding = true - } - - dependenciesInfo { - includeInApk = false - includeInBundle = false - } - - packagingOptions { - exclude '/META-INF/**' - exclude '/androidsupportmultidexversion.txt' - exclude '/org/bouncycastle/**' - exclude '/kotlin/**' - exclude '/kotlinx/**' - exclude '/okhttp3/**' - } - - kotlinOptions { - jvmTarget = '1.8' - } -} - -androidExtensions { - experimental = true -} - -dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation project(':app:shared') - implementation project(':app:signing') - - implementation 'com.github.topjohnwu:jtar:1.0.0' - implementation 'com.jakewharton.timber:timber:4.7.1' - implementation 'com.github.pwittchen:reactivenetwork-rx2:3.0.8' - - implementation 'io.reactivex.rxjava2:rxjava:2.2.19' - implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0' - implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' - - implementation "org.jetbrains.kotlin:kotlin-stdlib:${vKotlin}" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${vKotlin}" - - def vBAdapt = '4.0.0' - def bindingAdapter = 'me.tatarka.bindingcollectionadapter2:bindingcollectionadapter' - implementation "${bindingAdapter}:${vBAdapt}" - implementation "${bindingAdapter}-recyclerview:${vBAdapt}" - - def vMarkwon = '4.4.0' - implementation "io.noties.markwon:core:${vMarkwon}" - implementation "io.noties.markwon:html:${vMarkwon}" - implementation "io.noties.markwon:image:${vMarkwon}" - implementation 'com.caverock:androidsvg:1.4' - - def vLibsu = '2.5.1' - implementation "com.github.topjohnwu.libsu:core:${vLibsu}" - implementation "com.github.topjohnwu.libsu:io:${vLibsu}" - - def vKoin = '2.1.6' - implementation "org.koin:koin-core:${vKoin}" - implementation "org.koin:koin-android:${vKoin}" - implementation "org.koin:koin-androidx-viewmodel:${vKoin}" - - def vRetrofit = '2.9.0' - implementation "com.squareup.retrofit2:retrofit:${vRetrofit}" - implementation "com.squareup.retrofit2:converter-moshi:${vRetrofit}" - implementation "com.squareup.retrofit2:converter-scalars:${vRetrofit}" - implementation "com.squareup.retrofit2:adapter-rxjava2:${vRetrofit}" - - def vOkHttp = '3.12.12' - implementation("com.squareup.okhttp3:okhttp") { - version { - strictly "$vOkHttp" - } - } - implementation "com.squareup.okhttp3:logging-interceptor:${vOkHttp}" - implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:${vOkHttp}") - - def vMoshi = '1.9.3' - implementation "com.squareup.moshi:moshi:${vMoshi}" - kapt "com.squareup.moshi:moshi-kotlin-codegen:${vMoshi}" - - def vRoom = '2.2.5' - implementation "androidx.room:room-runtime:${vRoom}" - implementation "androidx.room:room-rxjava2:${vRoom}" - kapt "androidx.room:room-compiler:${vRoom}" - - implementation "androidx.navigation:navigation-fragment-ktx:${vNav}" - implementation "androidx.navigation:navigation-ui-ktx:${vNav}" - - implementation 'androidx.biometric:biometric:1.0.1' - implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta7' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' - implementation 'androidx.browser:browser:1.2.0' - implementation 'androidx.preference:preference:1.1.1' - implementation 'androidx.recyclerview:recyclerview:1.1.0' - implementation 'androidx.fragment:fragment-ktx:1.2.5' - implementation 'androidx.work:work-runtime:2.3.4' - implementation 'androidx.transition:transition:1.3.1' - implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.core:core-ktx:1.3.0' - implementation 'com.google.android.material:material:1.2.0-beta01' -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 000000000..e0832f997 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,153 @@ +import java.util.* + +plugins { + id("com.android.application") + kotlin("android") + kotlin("android.extensions") + kotlin("kapt") + id("androidx.navigation.safeargs.kotlin") +} + +val props = Properties() +val vKotlin = "1.3.72" +val vNav = "2.3.0" + +kapt { + correctErrorTypes = true + useBuildCache = true + mapDiagnosticLocations = true + javacOptions { + option("-Xmaxerrs", 1000) + } +} + +android { + defaultConfig { + applicationId = "com.topjohnwu.magisk" + vectorDrawables.useSupportLibrary = true + multiDexEnabled = true + versionName = Config["appVersion"] + versionCode = Config["appVersionCode"]?.toInt() + buildConfigField("int", "LATEST_MAGISK", Config["versionCode"] ?: "Integer.MAX_VALUE") + + javaCompileOptions { + annotationProcessorOptions { + arguments = mapOf("room.incremental" to "true") + } + } + } + + buildTypes { + getByName("release") { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + + buildFeatures { + dataBinding = true + } + + dependenciesInfo { + includeInApk = false + includeInBundle = false + } + + packagingOptions { + exclude("/META-INF/**") + exclude("/androidsupportmultidexversion.txt") + exclude("/org/bouncycastle/**") + exclude("/kotlin/**") + exclude("/kotlinx/**") + exclude("/okhttp3/**") + } + + kotlinOptions { + jvmTarget = "1.8" + } +} + +androidExtensions { + isExperimental = true +} + +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + implementation(project(":app:shared")) + implementation(project(":app:signing")) + + implementation("com.github.topjohnwu:jtar:1.0.0") + implementation("com.jakewharton.timber:timber:4.7.1") + implementation("com.github.pwittchen:reactivenetwork-rx2:3.0.8") + + implementation("io.reactivex.rxjava2:rxjava:2.2.19") + implementation("io.reactivex.rxjava2:rxkotlin:2.4.0") + implementation("io.reactivex.rxjava2:rxandroid:2.1.1") + + implementation("org.jetbrains.kotlin:kotlin-stdlib:${Deps.vKotlin}") + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Deps.vKotlin}") + + val vBAdapt = "4.0.0" + val bindingAdapter = "me.tatarka.bindingcollectionadapter2:bindingcollectionadapter" + implementation("${bindingAdapter}:${vBAdapt}") + implementation("${bindingAdapter}-recyclerview:${vBAdapt}") + + val vMarkwon = "4.4.0" + implementation("io.noties.markwon:core:${vMarkwon}") + implementation("io.noties.markwon:html:${vMarkwon}") + implementation("io.noties.markwon:image:${vMarkwon}") + implementation("com.caverock:androidsvg:1.4") + + val vLibsu = "2.5.1" + implementation("com.github.topjohnwu.libsu:core:${vLibsu}") + implementation("com.github.topjohnwu.libsu:io:${vLibsu}") + + val vKoin = "2.1.6" + implementation("org.koin:koin-core:${vKoin}") + implementation("org.koin:koin-android:${vKoin}") + implementation("org.koin:koin-androidx-viewmodel:${vKoin}") + + val vRetrofit = "2.9.0" + implementation("com.squareup.retrofit2:retrofit:${vRetrofit}") + implementation("com.squareup.retrofit2:converter-moshi:${vRetrofit}") + implementation("com.squareup.retrofit2:converter-scalars:${vRetrofit}") + implementation("com.squareup.retrofit2:adapter-rxjava2:${vRetrofit}") + + val vOkHttp = "3.12.12" + implementation("com.squareup.okhttp3:okhttp") { + version { + strictly(vOkHttp) + } + } + implementation("com.squareup.okhttp3:logging-interceptor:${vOkHttp}") + implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:${vOkHttp}") + + val vMoshi = "1.9.3" + implementation("com.squareup.moshi:moshi:${vMoshi}") + kapt("com.squareup.moshi:moshi-kotlin-codegen:${vMoshi}") + + val vRoom = "2.2.5" + implementation("androidx.room:room-runtime:${vRoom}") + implementation("androidx.room:room-rxjava2:${vRoom}") + kapt("androidx.room:room-compiler:${vRoom}") + + implementation("androidx.navigation:navigation-fragment-ktx:${Deps.vNav}") + implementation("androidx.navigation:navigation-ui-ktx:${Deps.vNav}") + + implementation("androidx.biometric:biometric:1.0.1") + implementation("androidx.constraintlayout:constraintlayout:2.0.0-beta7") + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") + implementation("androidx.browser:browser:1.2.0") + implementation("androidx.preference:preference:1.1.1") + implementation("androidx.recyclerview:recyclerview:1.1.0") + implementation("androidx.fragment:fragment-ktx:1.2.5") + implementation("androidx.work:work-runtime:2.3.4") + implementation("androidx.transition:transition:1.3.1") + implementation("androidx.multidex:multidex:2.0.1") + implementation("androidx.core:core-ktx:1.3.0") + implementation("com.google.android.material:material:1.2.0-beta01") +} diff --git a/app/shared/build.gradle b/app/shared/build.gradle deleted file mode 100644 index 7251be266..000000000 --- a/app/shared/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -apply plugin: 'com.android.library' - -android { - defaultConfig { - vectorDrawables.useSupportLibrary = true - consumerProguardFiles 'proguard-rules.pro' - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) -} diff --git a/app/shared/build.gradle.kts b/app/shared/build.gradle.kts new file mode 100644 index 000000000..c7b74da83 --- /dev/null +++ b/app/shared/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("com.android.library") +} + +android { + defaultConfig { + vectorDrawables.useSupportLibrary = true + consumerProguardFiles("proguard-rules.pro") + } +} + +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) +} diff --git a/app/signing/build.gradle b/app/signing/build.gradle deleted file mode 100644 index ece4ba61b..000000000 --- a/app/signing/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -apply plugin: 'java-library' - -apply plugin: 'com.github.johnrengelman.shadow' -apply plugin: 'java' - -sourceCompatibility = "1.8" -targetCompatibility = "1.8" - -jar { - manifest { - attributes 'Main-Class': 'com.topjohnwu.signing.ZipSigner' - } -} - -shadowJar { - baseName = 'zipsigner' - classifier = null - version = 3.0 -} - -buildscript { - repositories { - jcenter() - } - dependencies { - classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' - } -} - -repositories { - jcenter() -} - -dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') - - api "org.bouncycastle:bcprov-jdk15on:1.65.01" - api "org.bouncycastle:bcpkix-jdk15on:1.65" -} diff --git a/app/signing/build.gradle.kts b/app/signing/build.gradle.kts new file mode 100644 index 000000000..717dff915 --- /dev/null +++ b/app/signing/build.gradle.kts @@ -0,0 +1,35 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + id("java-library") + id("java") + id("com.github.johnrengelman.shadow") version "6.0.0" +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +val jar by tasks.getting(Jar::class) { + manifest { + attributes["Main-Class"] = "com.topjohnwu.signing.ZipSigner" + } +} + +val shadowJar by tasks.getting(ShadowJar::class) { + baseName = "zipsigner" + classifier = null + version = "3.0" +} + +repositories { + jcenter() +} + +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + + api("org.bouncycastle:bcprov-jdk15on:1.65.01") + api("org.bouncycastle:bcpkix-jdk15on:1.65") +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 65dc76aaa..000000000 --- a/build.gradle +++ /dev/null @@ -1,128 +0,0 @@ -import java.nio.file.Paths - -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - ext.vKotlin = '1.3.72' - ext.vNav = '2.3.0' - - repositories { - google() - jcenter() - maven { url 'http://storage.googleapis.com/r8-releases/raw' } - maven { url 'https://kotlin.bintray.com/kotlinx' } - } - dependencies { - classpath 'com.android.tools.build:gradle:4.0.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${vKotlin}" - classpath "androidx.navigation:navigation-safe-args-gradle-plugin:${vNav}" - - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} - -String.metaClass.toFile = { new File(delegate) } -def configFile = rootProject.findProperty('configPath')?.toFile() ?: rootProject.file('config.prop') -if (!configFile.exists()) - throw new GradleException("Please setup config.prop") - -def props = new Properties() -configFile.withInputStream { is -> props.load(is) } -ext.props = props - -subprojects { - repositories { - google() - jcenter() - maven { url "https://jitpack.io" } - maven { url "http://oss.sonatype.org/content/repositories/snapshots" } - } - - afterEvaluate { module -> - if (getPlugins().hasPlugin('com.android.library') || - getPlugins().hasPlugin('com.android.application')) { - android { - compileSdkVersion 30 - buildToolsVersion '30.0.0' - - defaultConfig { - if (minSdkVersion == null) - minSdkVersion 17 - targetSdkVersion 28 - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - } - } - - tasks.whenTaskAdded { task -> - if (task.name == 'processReleaseResources') { - task.finalizedBy tasks.create('optimizeReleaseResources') { - doLast { - def aapt2 = Paths.get(android.sdkDirectory.path, - 'build-tools', android.buildToolsVersion, 'aapt2') - def zip = Paths.get(project.buildDir.path, 'intermediates', - 'processed_res', 'release', 'out', 'resources-release.ap_') - def optimized = new File("${zip}.opt") - def cmd = exec { - commandLine aapt2, 'optimize', '--collapse-resource-names', - '--shorten-resource-paths', '-o', optimized, zip - ignoreExitValue true - } - if (cmd.exitValue == 0) { - optimized.renameTo("$zip") - } - } - } - } - } - - if (getPlugins().hasPlugin('java')) { - tasks.withType(JavaCompile) { - // If building with JDK 9+, we need additional flags to generate compatible bytecode - if (JavaVersion.current() > JavaVersion.VERSION_1_8) { - options.compilerArgs += ['--release', '8'] - } - } - } - - if (module.name == 'app' || module.name == 'stub') { - android { - signingConfigs { - config { - if (props.containsKey('keyStore')) { - storeFile new File(props['keyStore']) - storePassword props['keyStorePass'] - keyAlias props['keyAlias'] - keyPassword props['keyPass'] - } - } - } - - buildTypes { - debug { - // If keystore exists, sign the APK with custom signature - if (signingConfigs.config.storeFile?.exists()) - signingConfig signingConfigs.config - } - release { - signingConfig signingConfigs.config - } - } - - lintOptions { - disable 'MissingTranslation' - } - } - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..5ec7498f0 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,125 @@ +import com.android.build.gradle.BaseExtension +import java.nio.file.Paths + +plugins { + id("MagiskPlugin") +} + +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + google() + jcenter() + maven { url = uri("http://storage.googleapis.com/r8-releases/raw") } + maven { url = uri("https://kotlin.bintray.com/kotlinx") } + } + + dependencies { + classpath("com.android.tools.build:gradle:4.0.0") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Deps.vKotlin}") + classpath("androidx.navigation:navigation-safe-args-gradle-plugin:${Deps.vNav}") + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +tasks.register("clean",Delete::class){ + delete(rootProject.buildDir) +} + +val Project.android get() = extensions.getByName("android") + +fun Task.applyOptimize() = doLast { + val aapt2 = Paths.get(project.android.sdkDirectory.path, + "build-tools", project.android.buildToolsVersion, "aapt2") + val zip = Paths.get(project.buildDir.path, "intermediates", + "processed_res", "release", "out", "resources-release.ap_") + val optimized = File("${zip}.opt") + val cmd = exec { + commandLine(aapt2, "optimize", "--collapse-resource-names", + "--shorten-resource-paths", "-o", optimized, zip) + isIgnoreExitValue = true + } + if (cmd.exitValue == 0) { + optimized.renameTo(zip.toFile()) + } +} + +subprojects { + repositories { + google() + jcenter() + maven { url = uri("https://jitpack.io") } + maven { url = uri("http://oss.sonatype.org/content/repositories/snapshots") } + } + + afterEvaluate { + if (plugins.hasPlugin("com.android.library") || + plugins.hasPlugin("com.android.application")) { + android.apply { + compileSdkVersion(30) + buildToolsVersion = "30.0.0" + + defaultConfig { + if (minSdkVersion == null) + minSdkVersion(17) + targetSdkVersion(28) + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + } + } + + if (plugins.hasPlugin("java")) { + tasks.withType { + // If building with JDK 9+, we need additional flags to generate compatible bytecode + if (JavaVersion.current() > JavaVersion.VERSION_1_8) { + options.compilerArgs.addAll(listOf("--release", "8")) + } + } + } + + tasks.whenTaskAdded { + if (name == "processReleaseResources") { + finalizedBy(tasks.create("optimizeReleaseResources").applyOptimize()) + } + } + + if (name == "app" || name == "stub") { + android.apply { + signingConfigs { + create("config") { + Config["keyStore"]?.also { + storeFile = File(it) + storePassword = Config["keyStorePass"] + keyAlias = Config["keyAlias"] + keyPassword = Config["keyPass"] + } + } + } + + buildTypes { + signingConfigs.getByName("config").also { + getByName("debug") { + // If keystore exists, sign the APK with custom signature + if (it.storeFile?.exists() == true) + signingConfig = it + } + getByName("release") { + signingConfig = it + } + } + } + + lintOptions { + disable("MissingTranslation") + } + } + } + } +} diff --git a/buildSrc/.gitignore b/buildSrc/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/buildSrc/.gitignore @@ -0,0 +1 @@ +/build diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 000000000..60da16e4f --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + `kotlin-dsl` +} +repositories { + jcenter() +} + +gradlePlugin { + plugins { + register("MagiskPlugin") { + id = "MagiskPlugin" + implementationClass = "MagiskPlugin" + } + } +} diff --git a/buildSrc/src/main/java/BuildSource.kt b/buildSrc/src/main/java/BuildSource.kt new file mode 100644 index 000000000..c68292028 --- /dev/null +++ b/buildSrc/src/main/java/BuildSource.kt @@ -0,0 +1,29 @@ + +import org.gradle.api.GradleException +import org.gradle.api.Plugin +import org.gradle.api.Project +import java.io.File +import java.util.* + +object Deps { + const val vKotlin = "1.3.72" + const val vNav = "2.3.0" +} + +private val props = Properties() + +object Config { + operator fun get(key: String) = props[key] as? String + fun contains(key: String) = props.containsKey(key) +} + +class MagiskPlugin : Plugin { + override fun apply(project: Project) { + val file = project.findProperty("configPath")?.let { File(it as String) } + ?: project.file("config.prop") + if (!file.exists()) + throw GradleException("Please setup config.prop") + + file.inputStream().use { props.load(it) } + } +} diff --git a/native/build.gradle b/native/build.gradle deleted file mode 100644 index 467efa834..000000000 --- a/native/build.gradle +++ /dev/null @@ -1,22 +0,0 @@ -apply plugin: 'com.android.library' - -android { - - ndkVersion '99.99.99' - - externalNativeBuild { - ndkBuild { - path 'jni/Android.mk' - } - } - - defaultConfig { - externalNativeBuild { - ndkBuild { - // Pass arguments to ndk-build. - arguments('B_MAGISK=1', 'B_INIT64=1', 'B_BOOT=1', 'B_TEST=1', - 'MAGISK_DEBUG=1', 'MAGISK_VERSION=debug', 'MAGISK_VER_CODE=INT_MAX') - } - } - } -} diff --git a/native/build.gradle.kts b/native/build.gradle.kts new file mode 100644 index 000000000..9ed21750a --- /dev/null +++ b/native/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + id("com.android.library") +} + +android { + + ndkVersion = "99.99.99" + + externalNativeBuild { + ndkBuild { + path("jni/Android.mk") + } + } + + defaultConfig { + externalNativeBuild { + ndkBuild { + // Pass arguments to ndk-build. + arguments("B_MAGISK=1", "B_INIT64=1", "B_BOOT=1", "B_TEST=1", + "MAGISK_DEBUG=1", "MAGISK_VERSION=debug", "MAGISK_VER_CODE=INT_MAX") + } + } + } +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 9658b336d..000000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app', ':app:signing', ':app:shared', ':native', ':stub' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..cdcafdaf4 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +include(":app", ":app:signing", ":app:shared", ":native", ":stub") diff --git a/stub/build.gradle b/stub/build.gradle deleted file mode 100644 index 732b92bef..000000000 --- a/stub/build.gradle +++ /dev/null @@ -1,24 +0,0 @@ -apply plugin: 'com.android.application' - -android { - defaultConfig { - applicationId 'com.topjohnwu.magisk' - versionCode 1 - versionName props['appVersion'] - buildConfigField 'String', 'DEV_CHANNEL', props['DEV_CHANNEL'] ?: 'null' - } - - buildTypes { - release { - minifyEnabled true - shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), - 'proguard-rules.pro' - } - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation project(':app:shared') -} diff --git a/stub/build.gradle.kts b/stub/build.gradle.kts new file mode 100644 index 000000000..bd749bd35 --- /dev/null +++ b/stub/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + id("com.android.application") +} + +android { + defaultConfig { + applicationId = "com.topjohnwu.magisk" + versionCode = 1 + versionName = Config["appVersion"] + buildConfigField("String", "DEV_CHANNEL", Config["DEV_CHANNEL"] ?: "null") + } + + buildTypes { + getByName("release") { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } +} + +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + implementation(project(":app:shared")) +}