[gradle] Clean gradle code (#773)
This commit is contained in:
parent
c38c280dab
commit
7254ed4d79
|
|
@ -17,8 +17,8 @@
|
||||||
* Copyright (C) 2021 LSPosed Contributors
|
* Copyright (C) 2021 LSPosed Contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.android.build.api.variant.impl.ApplicationVariantImpl
|
|
||||||
import com.android.build.api.component.analytics.AnalyticsEnabledApplicationVariant
|
import com.android.build.api.component.analytics.AnalyticsEnabledApplicationVariant
|
||||||
|
import com.android.build.api.variant.impl.ApplicationVariantImpl
|
||||||
import com.android.build.gradle.internal.dsl.BuildType
|
import com.android.build.gradle.internal.dsl.BuildType
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
@ -75,19 +75,8 @@ android {
|
||||||
versionCode = verCode
|
versionCode = verCode
|
||||||
versionName = verName
|
versionName = verName
|
||||||
resourceConfigurations += arrayOf(
|
resourceConfigurations += arrayOf(
|
||||||
"en",
|
"en", "zh-rCN", "zh-rTW", "zh-rHK", "ru", "uk", "nl", "ko", "fr", "de",
|
||||||
"zh-rCN",
|
"it", "pt", "es",
|
||||||
"zh-rTW",
|
|
||||||
"zh-rHK",
|
|
||||||
"ru",
|
|
||||||
"uk",
|
|
||||||
"nl",
|
|
||||||
"ko",
|
|
||||||
"fr",
|
|
||||||
"de",
|
|
||||||
"it",
|
|
||||||
"pt",
|
|
||||||
"es",
|
|
||||||
)
|
)
|
||||||
buildConfigField("long", "BUILD_TIME", Instant.now().epochSecond.toString())
|
buildConfigField("long", "BUILD_TIME", Instant.now().epochSecond.toString())
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +88,6 @@ android {
|
||||||
|
|
||||||
lint {
|
lint {
|
||||||
disable += "MissingTranslation"
|
disable += "MissingTranslation"
|
||||||
disable += "ExtraTranslation"
|
|
||||||
isAbortOnError = true
|
isAbortOnError = true
|
||||||
isCheckReleaseBuilds = false
|
isCheckReleaseBuilds = false
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +188,6 @@ tasks.whenTaskAdded {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
val glideVersion = "4.12.0"
|
val glideVersion = "4.12.0"
|
||||||
val markwonVersion = "4.6.2"
|
|
||||||
val okhttpVersion = "4.9.1"
|
val okhttpVersion = "4.9.1"
|
||||||
val navVersion = "2.3.5"
|
val navVersion = "2.3.5"
|
||||||
annotationProcessor("com.github.bumptech.glide:compiler:$glideVersion")
|
annotationProcessor("com.github.bumptech.glide:compiler:$glideVersion")
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ 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
|
||||||
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||||||
import org.gradle.internal.os.OperatingSystem
|
import org.gradle.internal.os.OperatingSystem
|
||||||
import org.jetbrains.kotlin.daemon.common.toHexString
|
import org.jetbrains.kotlin.daemon.common.toHexString
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
|
|
@ -162,11 +163,9 @@ androidComponents.onVariants { v ->
|
||||||
variant.variantData.registerJavaGeneratingTask(signInfoTask, arrayListOf(outSrcDir))
|
variant.variantData.registerJavaGeneratingTask(signInfoTask, arrayListOf(outSrcDir))
|
||||||
}
|
}
|
||||||
|
|
||||||
val prepareMagiskFilesTask = task("prepareMagiskFiles$variantCapped") {
|
val prepareMagiskFilesTask = task("prepareMagiskFiles$variantCapped", Sync::class) {
|
||||||
dependsOn("assemble$variantCapped")
|
dependsOn("assemble$variantCapped")
|
||||||
dependsOn(":app:assemble$variantCapped")
|
dependsOn(":app:assemble$variantCapped")
|
||||||
doLast {
|
|
||||||
sync {
|
|
||||||
into(magiskDir)
|
into(magiskDir)
|
||||||
from("${rootProject.projectDir}/README.md")
|
from("${rootProject.projectDir}/README.md")
|
||||||
from("$projectDir/magisk_module") {
|
from("$projectDir/magisk_module") {
|
||||||
|
|
@ -181,36 +180,19 @@ androidComponents.onVariants { v ->
|
||||||
"authorList" to authors,
|
"authorList" to authors,
|
||||||
"minRiruVersionName" to moduleMinRiruVersionName
|
"minRiruVersionName" to moduleMinRiruVersionName
|
||||||
)
|
)
|
||||||
filter(
|
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
|
||||||
mapOf("eol" to FixCrLfFilter.CrLf.newInstance("lf")),
|
|
||||||
FixCrLfFilter::class.java
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
from("${projectDir}/magisk_module") {
|
from("${projectDir}/magisk_module") {
|
||||||
include("riru.sh")
|
include("riru.sh")
|
||||||
filter { line ->
|
val tokens = mapOf(
|
||||||
line.replace("%%%RIRU_MODULE_LIB_NAME%%%", "lspd")
|
"RIRU_MODULE_LIB_NAME" to "lspd",
|
||||||
.replace(
|
"RIRU_MODULE_API_VERSION" to moduleMaxRiruApiVersion.toString(),
|
||||||
"%%%RIRU_MODULE_API_VERSION%%%",
|
"RIRU_MODULE_MIN_API_VERSION" to moduleMinRiruApiVersion.toString(),
|
||||||
moduleMaxRiruApiVersion.toString()
|
"RIRU_MODULE_MIN_RIRU_VERSION_NAME" to moduleMinRiruVersionName,
|
||||||
)
|
"RIRU_MODULE_DEBUG" to if (variantLowered == "debug") "true" else "false",
|
||||||
.replace(
|
|
||||||
"%%%RIRU_MODULE_MIN_API_VERSION%%%",
|
|
||||||
moduleMinRiruApiVersion.toString()
|
|
||||||
)
|
|
||||||
.replace(
|
|
||||||
"%%%RIRU_MODULE_MIN_RIRU_VERSION_NAME%%%",
|
|
||||||
moduleMinRiruVersionName
|
|
||||||
)
|
|
||||||
.replace(
|
|
||||||
"%%RIRU_MODULE_DEBUG%%",
|
|
||||||
if (variantLowered == "debug") "true" else "false"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
filter(
|
|
||||||
mapOf("eol" to FixCrLfFilter.CrLf.newInstance("lf")),
|
|
||||||
FixCrLfFilter::class.java
|
|
||||||
)
|
)
|
||||||
|
filter<ReplaceTokens>("tokens" to tokens)
|
||||||
|
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
|
||||||
}
|
}
|
||||||
from("${project(":app").buildDir}/outputs/apk/${variantLowered}") {
|
from("${project(":app").buildDir}/outputs/apk/${variantLowered}") {
|
||||||
include("*.apk")
|
include("*.apk")
|
||||||
|
|
@ -226,7 +208,7 @@ androidComponents.onVariants { v ->
|
||||||
from(dexOutPath)
|
from(dexOutPath)
|
||||||
rename("classes.dex", "lspd.dex")
|
rename("classes.dex", "lspd.dex")
|
||||||
}
|
}
|
||||||
}
|
doLast {
|
||||||
fileTree(magiskDir).visit {
|
fileTree(magiskDir).visit {
|
||||||
if (isDirectory) return@visit
|
if (isDirectory) return@visit
|
||||||
val md = MessageDigest.getInstance("SHA-256")
|
val md = MessageDigest.getInstance("SHA-256")
|
||||||
|
|
@ -249,35 +231,20 @@ androidComponents.onVariants { v ->
|
||||||
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(adb, "push", zipFileName, "/data/local/tmp/")
|
commandLine(adb, "push", zipFileName, "/data/local/tmp/")
|
||||||
if (isWindows) {
|
|
||||||
commandLine("cmd", "/c", commands.joinToString(" "))
|
|
||||||
} else {
|
|
||||||
commandLine(commands)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val flashTask = task("flash${variantCapped}", Exec::class) {
|
val flashTask = task("flash${variantCapped}", Exec::class) {
|
||||||
dependsOn(pushTask)
|
dependsOn(pushTask)
|
||||||
workingDir("${projectDir}/release")
|
workingDir("${projectDir}/release")
|
||||||
val commands = arrayOf(
|
commandLine(
|
||||||
adb, "shell", "su", "-c",
|
adb, "shell", "su", "-c",
|
||||||
"magisk --install-module /data/local/tmp/${zipFileName}"
|
"magisk --install-module /data/local/tmp/${zipFileName}"
|
||||||
)
|
)
|
||||||
if (isWindows) {
|
|
||||||
commandLine("cmd", "/c", commands.joinToString(" "))
|
|
||||||
} else {
|
|
||||||
commandLine(commands)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
task("flashAndReboot${variantCapped}", Exec::class) {
|
task("flashAndReboot${variantCapped}", Exec::class) {
|
||||||
dependsOn(flashTask)
|
dependsOn(flashTask)
|
||||||
workingDir("${projectDir}/release")
|
workingDir("${projectDir}/release")
|
||||||
val commands = arrayOf(adb, "shell", "reboot")
|
commandLine(adb, "shell", "reboot")
|
||||||
if (isWindows) {
|
|
||||||
commandLine("cmd", "/c", commands.joinToString(" "))
|
|
||||||
} else {
|
|
||||||
commandLine(commands)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/sbin/sh
|
#!/sbin/sh
|
||||||
RIRU_MODULE_LIB_NAME="%%%RIRU_MODULE_LIB_NAME%%%"
|
RIRU_MODULE_LIB_NAME="@RIRU_MODULE_LIB_NAME@"
|
||||||
|
|
||||||
# Variables for customize.sh
|
# Variables for customize.sh
|
||||||
RIRU_API=0
|
RIRU_API=0
|
||||||
|
|
@ -8,10 +8,10 @@ RIRU_VERSION_CODE=0
|
||||||
RIRU_VERSION_NAME=""
|
RIRU_VERSION_NAME=""
|
||||||
|
|
||||||
# Used by /data/adb/riru/util_functions.sh
|
# Used by /data/adb/riru/util_functions.sh
|
||||||
RIRU_MODULE_API_VERSION=%%%RIRU_MODULE_API_VERSION%%%
|
RIRU_MODULE_API_VERSION=@RIRU_MODULE_API_VERSION@
|
||||||
RIRU_MODULE_MIN_API_VERSION=%%%RIRU_MODULE_MIN_API_VERSION%%%
|
RIRU_MODULE_MIN_API_VERSION=@RIRU_MODULE_MIN_API_VERSION@
|
||||||
RIRU_MODULE_MIN_RIRU_VERSION_NAME="%%%RIRU_MODULE_MIN_RIRU_VERSION_NAME%%%"
|
RIRU_MODULE_MIN_RIRU_VERSION_NAME="@RIRU_MODULE_MIN_RIRU_VERSION_NAME@"
|
||||||
RIRU_MODULE_DEBUG=%%RIRU_MODULE_DEBUG%%
|
RIRU_MODULE_DEBUG=@RIRU_MODULE_DEBUG@
|
||||||
|
|
||||||
if [ "$MAGISK_VER_CODE" -ge 21000 ]; then
|
if [ "$MAGISK_VER_CODE" -ge 21000 ]; then
|
||||||
MAGISK_CURRENT_RIRU_MODULE_PATH=$(magisk --path)/.magisk/modules/riru-core
|
MAGISK_CURRENT_RIRU_MODULE_PATH=$(magisk --path)/.magisk/modules/riru-core
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue