2020-07-04 06:53:31 -07:00
|
|
|
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("https://kotlin.bintray.com/kotlinx") }
|
|
|
|
}
|
|
|
|
|
2021-02-05 04:41:01 -08:00
|
|
|
val vNav = "2.3.3"
|
2020-08-15 05:43:28 -07:00
|
|
|
extra["vNav"] = vNav
|
|
|
|
|
2020-07-04 06:53:31 -07:00
|
|
|
dependencies {
|
2021-01-22 02:28:53 -08:00
|
|
|
classpath("com.android.tools.build:gradle:4.1.2")
|
2021-02-05 04:41:01 -08:00
|
|
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30")
|
2020-08-15 05:43:28 -07:00
|
|
|
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:${vNav}")
|
2020-07-04 06:53:31 -07:00
|
|
|
|
|
|
|
// NOTE: Do not place your application dependencies here; they belong
|
|
|
|
// in the individual module build.gradle files
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-06 06:30:45 +08:00
|
|
|
tasks.register("clean", Delete::class) {
|
2020-07-04 06:53:31 -07:00
|
|
|
delete(rootProject.buildDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
val Project.android get() = extensions.getByName<BaseExtension>("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",
|
2020-10-17 06:32:49 -07:00
|
|
|
"shrunk_processed_res", "release", "resources-release-stripped.ap_")
|
2020-07-04 06:53:31 -07:00
|
|
|
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) {
|
2020-10-17 06:32:49 -07:00
|
|
|
zip.toFile().delete()
|
2020-07-04 06:53:31 -07:00
|
|
|
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)
|
2020-08-15 05:43:28 -07:00
|
|
|
buildToolsVersion = "30.0.2"
|
2020-10-17 06:42:34 -07:00
|
|
|
ndkPath = "${System.getenv("ANDROID_SDK_ROOT")}/ndk/magisk"
|
2020-07-04 06:53:31 -07:00
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
if (minSdkVersion == null)
|
|
|
|
minSdkVersion(17)
|
2021-01-22 05:03:33 -08:00
|
|
|
targetSdkVersion(30)
|
2020-07-04 06:53:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
|
|
targetCompatibility = JavaVersion.VERSION_1_8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugins.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.addAll(listOf("--release", "8"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.whenTaskAdded {
|
2020-10-17 06:32:49 -07:00
|
|
|
if (name == "shrinkReleaseRes") {
|
|
|
|
finalizedBy(tasks.create("optimizeReleaseRes").applyOptimize())
|
2020-07-04 06:53:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name == "app" || name == "stub") {
|
|
|
|
android.apply {
|
|
|
|
signingConfigs {
|
|
|
|
create("config") {
|
|
|
|
Config["keyStore"]?.also {
|
2020-08-14 00:40:24 +08:00
|
|
|
storeFile = rootProject.file(it)
|
2020-07-04 06:53:31 -07:00
|
|
|
storePassword = Config["keyStorePass"]
|
|
|
|
keyAlias = Config["keyAlias"]
|
|
|
|
keyPassword = Config["keyPass"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
signingConfigs.getByName("config").also {
|
|
|
|
getByName("debug") {
|
2020-12-06 06:30:45 +08:00
|
|
|
signingConfig = if (it.storeFile?.exists() == true) it
|
|
|
|
else signingConfigs.getByName("debug")
|
2020-07-04 06:53:31 -07:00
|
|
|
}
|
|
|
|
getByName("release") {
|
2020-12-06 06:30:45 +08:00
|
|
|
signingConfig = if (it.storeFile?.exists() == true) it
|
|
|
|
else signingConfigs.getByName("debug")
|
2020-07-04 06:53:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lintOptions {
|
|
|
|
disable("MissingTranslation")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|