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