[gradle] Update AGP (#528)
This commit is contained in:
parent
5d8aae4bec
commit
476bd8f7c2
|
|
@ -16,7 +16,9 @@
|
|||
*
|
||||
* Copyright (C) 2021 LSPosed Contributors
|
||||
*/
|
||||
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
|
||||
|
||||
import com.android.build.api.variant.impl.ApplicationVariantImpl
|
||||
import com.android.build.gradle.internal.dsl.BuildType
|
||||
import java.nio.file.Paths
|
||||
|
||||
plugins {
|
||||
|
|
@ -41,21 +43,35 @@ val androidKeyAlias: String? by rootProject
|
|||
val androidKeyPassword: String? by rootProject
|
||||
|
||||
android {
|
||||
compileSdkVersion(androidCompileSdkVersion)
|
||||
compileSdk = androidCompileSdkVersion
|
||||
ndkVersion = androidCompileNdkVersion
|
||||
buildToolsVersion(androidBuildToolsVersion)
|
||||
buildToolsVersion = androidBuildToolsVersion
|
||||
|
||||
buildFeatures {
|
||||
viewBinding = true
|
||||
buildConfig = true
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId(defaultManagerPackageName)
|
||||
minSdkVersion(androidMinSdkVersion)
|
||||
targetSdkVersion(androidTargetSdkVersion)
|
||||
versionCode(verCode)
|
||||
versionName(verName)
|
||||
resConfigs("en", "zh-rCN", "zh-rTW", "zh-rHK", "ru", "uk", "nl", "ko", "fr", "de", "it", "pt")
|
||||
applicationId = defaultManagerPackageName
|
||||
minSdk = androidMinSdkVersion
|
||||
targetSdk = androidTargetSdkVersion
|
||||
versionCode = verCode
|
||||
versionName = verName
|
||||
resourceConfigurations += arrayOf(
|
||||
"en",
|
||||
"zh-rCN",
|
||||
"zh-rTW",
|
||||
"zh-rHK",
|
||||
"ru",
|
||||
"uk",
|
||||
"nl",
|
||||
"ko",
|
||||
"fr",
|
||||
"de",
|
||||
"it",
|
||||
"pt",
|
||||
)
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
|
@ -96,39 +112,46 @@ android {
|
|||
|
||||
buildTypes {
|
||||
signingConfigs.named("config").get().also {
|
||||
named("debug") {
|
||||
debug {
|
||||
if (it.storeFile?.exists() == true) signingConfig = it
|
||||
}
|
||||
named("release") {
|
||||
release {
|
||||
signingConfig = if (it.storeFile?.exists() == true) it
|
||||
else signingConfigs.named("debug").get()
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
(this as BuildType).isShrinkResources = true
|
||||
proguardFiles("proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
applicationVariants.all {
|
||||
outputs.map { it as BaseVariantOutputImpl }.forEach { output ->
|
||||
output.outputFileName = "LSPosedManager-${verName}-${verCode}-${buildType.name}.apk"
|
||||
}
|
||||
androidComponents.onVariants { v ->
|
||||
val variant = v as ApplicationVariantImpl
|
||||
variant.outputs.forEach {
|
||||
it.outputFileName.set("LSPosedManager-${verName}-${verCode}-${variant.name}.apk")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val optimizeReleaseRes = task("optimizeReleaseRes").doLast {
|
||||
val aapt2 = Paths.get(
|
||||
project.android.sdkDirectory.path,
|
||||
"build-tools",
|
||||
project.android.buildToolsVersion,
|
||||
"aapt2"
|
||||
val aapt2 = File(
|
||||
androidComponents.sdkComponents.sdkDirectory.get().asFile,
|
||||
"build-tools/${androidBuildToolsVersion}/aapt2"
|
||||
)
|
||||
val mapping = Paths.get(
|
||||
project.buildDir.path,
|
||||
"outputs",
|
||||
"mapping",
|
||||
"release",
|
||||
"shortening.txt"
|
||||
)
|
||||
val zip = Paths.get(
|
||||
project.buildDir.path,
|
||||
"intermediates",
|
||||
"optimized_processed_res",
|
||||
"shrunk_processed_res",
|
||||
"release",
|
||||
"resources-release-optimize.ap_"
|
||||
"resources-release-stripped.ap_"
|
||||
)
|
||||
val optimized = File("${zip}.opt")
|
||||
val cmd = exec {
|
||||
|
|
@ -136,6 +159,8 @@ val optimizeReleaseRes = task("optimizeReleaseRes").doLast {
|
|||
aapt2, "optimize",
|
||||
"--collapse-resource-names",
|
||||
"--enable-sparse-encoding",
|
||||
"--shorten-resource-paths",
|
||||
"--resource-path-shortening-map", mapping,
|
||||
"-o", optimized,
|
||||
zip
|
||||
)
|
||||
|
|
@ -148,7 +173,7 @@ val optimizeReleaseRes = task("optimizeReleaseRes").doLast {
|
|||
}
|
||||
|
||||
tasks.whenTaskAdded {
|
||||
if (name == "optimizeReleaseResources") {
|
||||
if (name == "shrinkReleaseRes") {
|
||||
finalizedBy(optimizeReleaseRes)
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +187,7 @@ dependencies {
|
|||
implementation("androidx.browser:browser:1.3.0")
|
||||
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
|
||||
implementation("androidx.core:core:1.3.2")
|
||||
implementation("androidx.fragment:fragment:1.3.2")
|
||||
implementation("androidx.fragment:fragment:1.3.3")
|
||||
implementation("androidx.recyclerview:recyclerview:1.2.0")
|
||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||
implementation("com.caverock:androidsvg-aar:1.4")
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ buildscript {
|
|||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven("https://storage.googleapis.com/r8-releases/raw")
|
||||
}
|
||||
dependencies {
|
||||
classpath("com.android.tools:r8:3.0.34-dev")
|
||||
classpath("com.android.tools.build:gradle:7.0.0-alpha14")
|
||||
classpath("com.android.tools.build:gradle:7.0.0-alpha15")
|
||||
classpath("org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r")
|
||||
classpath(kotlin("gradle-plugin", version = "1.4.32"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
* Copyright (C) 2021 LSPosed Contributors
|
||||
*/
|
||||
|
||||
import com.android.build.api.variant.impl.ApplicationVariantImpl
|
||||
import com.android.build.gradle.BaseExtension
|
||||
import com.android.ide.common.signing.KeystoreHelper
|
||||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
|
|
@ -68,20 +69,20 @@ dependencies {
|
|||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion(androidCompileSdkVersion)
|
||||
compileSdk = androidCompileSdkVersion
|
||||
ndkVersion = androidCompileNdkVersion
|
||||
buildToolsVersion(androidBuildToolsVersion)
|
||||
buildToolsVersion = androidBuildToolsVersion
|
||||
|
||||
buildFeatures {
|
||||
prefab = true
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId("org.lsposed.lspd")
|
||||
minSdkVersion(androidMinSdkVersion)
|
||||
targetSdkVersion(androidTargetSdkVersion)
|
||||
versionCode(verCode)
|
||||
versionName(verName)
|
||||
applicationId = "org.lsposed.lspd"
|
||||
minSdk = androidMinSdkVersion
|
||||
targetSdk = androidTargetSdkVersion
|
||||
versionCode = verCode
|
||||
versionName = verName
|
||||
multiDexEnabled = false
|
||||
|
||||
externalNativeBuild {
|
||||
|
|
@ -123,17 +124,19 @@ android {
|
|||
}
|
||||
|
||||
buildTypes {
|
||||
named("debug") {
|
||||
debug {
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.addAll(arrayOf(
|
||||
"-DCMAKE_CXX_FLAGS_DEBUG=-Og",
|
||||
"-DCMAKE_C_FLAGS_DEBUG=-Og"
|
||||
))
|
||||
arguments.addAll(
|
||||
arrayOf(
|
||||
"-DCMAKE_CXX_FLAGS_DEBUG=-Og",
|
||||
"-DCMAKE_C_FLAGS_DEBUG=-Og"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
named("release") {
|
||||
release {
|
||||
isMinifyEnabled = true
|
||||
proguardFiles("proguard-rules.pro")
|
||||
|
||||
|
|
@ -156,12 +159,14 @@ android {
|
|||
"-Oz",
|
||||
"-DNDEBUG"
|
||||
).joinToString(" ")
|
||||
arguments.addAll(arrayOf(
|
||||
"-DCMAKE_CXX_FLAGS_RELEASE=$configFlags",
|
||||
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$configFlags",
|
||||
"-DCMAKE_C_FLAGS_RELEASE=$configFlags",
|
||||
"-DCMAKE_C_FLAGS_RELWITHDEBINFO=$configFlags"
|
||||
))
|
||||
arguments.addAll(
|
||||
arrayOf(
|
||||
"-DCMAKE_CXX_FLAGS_RELEASE=$configFlags",
|
||||
"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$configFlags",
|
||||
"-DCMAKE_C_FLAGS_RELEASE=$configFlags",
|
||||
"-DCMAKE_C_FLAGS_RELWITHDEBINFO=$configFlags"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -176,30 +181,32 @@ android {
|
|||
targetCompatibility(androidTargetCompatibility)
|
||||
sourceCompatibility(androidSourceCompatibility)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
android.applicationVariants.all {
|
||||
val variantCapped = name.capitalize()
|
||||
val variantLowered = name.toLowerCase()
|
||||
androidComponents.onVariants { v ->
|
||||
val variant = v as ApplicationVariantImpl
|
||||
val variantCapped = variant.name.capitalize()
|
||||
val variantLowered = variant.name.toLowerCase()
|
||||
val zipFileName = "$moduleName-$verName-$verCode-$variantLowered.zip"
|
||||
val magiskDir = "$buildDir/magisk/$variantLowered"
|
||||
|
||||
val app = rootProject.project(":app").extensions.getByName<BaseExtension>("android")
|
||||
val outSrcDir = file("$buildDir/generated/source/signInfo/${variantLowered}")
|
||||
val outSrc = file("$outSrcDir/org/lsposed/lspd/util/SignInfo.java")
|
||||
val signInfoTask = tasks.register("generate${variantCapped}SignInfo") {
|
||||
dependsOn(":app:validateSigning${variantCapped}")
|
||||
outputs.file(outSrc)
|
||||
doLast {
|
||||
val sign = app.buildTypes.named(buildType.name).get().signingConfig
|
||||
if (sign?.isSigningReady == true) {
|
||||
afterEvaluate {
|
||||
val app = rootProject.project(":app").extensions.getByName<BaseExtension>("android")
|
||||
val outSrcDir = file("$buildDir/generated/source/signInfo/${variantLowered}")
|
||||
val outSrc = file("$outSrcDir/org/lsposed/lspd/util/SignInfo.java")
|
||||
val signInfoTask = tasks.register("generate${variantCapped}SignInfo") {
|
||||
dependsOn(":app:validateSigning${variantCapped}")
|
||||
outputs.file(outSrc)
|
||||
doLast {
|
||||
val sign = app.buildTypes.named(variantLowered).get().signingConfig
|
||||
outSrc.parentFile.mkdirs()
|
||||
val certificateInfo = KeystoreHelper.getCertificateInfo(
|
||||
sign.storeType,
|
||||
sign.storeFile,
|
||||
sign.storePassword,
|
||||
sign.keyPassword,
|
||||
sign.keyAlias
|
||||
sign?.storeType,
|
||||
sign?.storeFile,
|
||||
sign?.storePassword,
|
||||
sign?.keyPassword,
|
||||
sign?.keyAlias
|
||||
)
|
||||
PrintStream(outSrc).apply {
|
||||
println("package org.lsposed.lspd.util;")
|
||||
|
|
@ -212,8 +219,8 @@ android.applicationVariants.all {
|
|||
}
|
||||
}
|
||||
}
|
||||
variant.variantData.registerJavaGeneratingTask(signInfoTask, arrayListOf(outSrcDir))
|
||||
}
|
||||
registerJavaGeneratingTask(signInfoTask.get(), outSrcDir)
|
||||
|
||||
val prepareMagiskFilesTask = task("prepareMagiskFiles$variantCapped") {
|
||||
dependsOn("assemble$variantCapped")
|
||||
|
|
@ -257,7 +264,7 @@ android.applicationVariants.all {
|
|||
)
|
||||
.replace(
|
||||
"%%RIRU_MODULE_DEBUG%%",
|
||||
if (buildType.name == "debug") "true" else "false"
|
||||
if (variantLowered == "debug") "true" else "false"
|
||||
)
|
||||
}
|
||||
filter(
|
||||
|
|
@ -273,7 +280,7 @@ android.applicationVariants.all {
|
|||
from("${buildDir}/intermediates/cmake/$variantLowered/obj")
|
||||
exclude("**/*.txt")
|
||||
}
|
||||
val dexOutPath = if (buildType.name == "release")
|
||||
val dexOutPath = if (variantLowered == "release")
|
||||
"$buildDir/intermediates/dex/$variantLowered/minify${variantCapped}WithR8" else
|
||||
"$buildDir/intermediates/dex/$variantLowered/mergeDex$variantCapped"
|
||||
into("framework") {
|
||||
|
|
@ -299,14 +306,11 @@ android.applicationVariants.all {
|
|||
from(magiskDir)
|
||||
}
|
||||
|
||||
val adb = androidComponents.sdkComponents.adb.get().asFile.absolutePath
|
||||
val pushTask = task("push${variantCapped}", Exec::class) {
|
||||
dependsOn(zipTask)
|
||||
workingDir("${projectDir}/release")
|
||||
val commands = arrayOf(
|
||||
android.adbExecutable, "push",
|
||||
zipFileName,
|
||||
"/data/local/tmp/"
|
||||
)
|
||||
val commands = arrayOf(adb, "push", zipFileName, "/data/local/tmp/")
|
||||
if (isWindows) {
|
||||
commandLine("cmd", "/c", commands.joinToString(" "))
|
||||
} else {
|
||||
|
|
@ -317,7 +321,7 @@ android.applicationVariants.all {
|
|||
dependsOn(pushTask)
|
||||
workingDir("${projectDir}/release")
|
||||
val commands = arrayOf(
|
||||
android.adbExecutable, "shell", "su", "-c",
|
||||
adb, "shell", "su", "-c",
|
||||
"magisk --install-module /data/local/tmp/${zipFileName}"
|
||||
)
|
||||
if (isWindows) {
|
||||
|
|
@ -329,7 +333,7 @@ android.applicationVariants.all {
|
|||
task("flashAndReboot${variantCapped}", Exec::class) {
|
||||
dependsOn(flashTask)
|
||||
workingDir("${projectDir}/release")
|
||||
val commands = arrayOf(android.adbExecutable, "shell", "reboot")
|
||||
val commands = arrayOf(adb, "shell", "reboot")
|
||||
if (isWindows) {
|
||||
commandLine("cmd", "/c", commands.joinToString(" "))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -13,3 +13,4 @@
|
|||
#Sat Jan 30 19:20:27 CST 202130.0.322.0.7026061
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
android.enableResourceOptimizations=false
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ val androidSourceCompatibility: JavaVersion by rootProject.extra
|
|||
val androidTargetCompatibility: JavaVersion by rootProject.extra
|
||||
|
||||
android {
|
||||
compileSdkVersion(androidTargetSdkVersion)
|
||||
buildToolsVersion(androidBuildToolsVersion)
|
||||
compileSdk = androidTargetSdkVersion
|
||||
buildToolsVersion = androidBuildToolsVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(androidMinSdkVersion)
|
||||
targetSdkVersion(androidTargetSdkVersion)
|
||||
minSdk = androidMinSdkVersion
|
||||
targetSdk = androidTargetSdkVersion
|
||||
consumerProguardFiles("proguard-rules.pro")
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
named("release") {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles("proguard-rules.pro")
|
||||
}
|
||||
|
|
@ -55,4 +55,4 @@ configurations.all {
|
|||
resolutionStrategy {
|
||||
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue