Skip to content

Commit

Permalink
refine gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
5ec1cff committed Jul 29, 2024
1 parent 643eb7d commit 3a515c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
14 changes: 0 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import com.android.build.gradle.AppExtension
import com.android.build.gradle.LibraryExtension
import org.jetbrains.kotlin.daemon.common.toHexString
import java.io.ByteArrayOutputStream
import java.security.MessageDigest

plugins {
alias(libs.plugins.agp.app) apply false
Expand Down Expand Up @@ -33,18 +31,6 @@ val verCode by extra(gitCommitCount)
val commitHash by extra(gitCommitHash)
val abiList by extra(listOf("arm64-v8a", "x86_64"))

fun calculateChecksum(): String {
return MessageDigest.getInstance("SHA-256").run {
update(moduleId.toByteArray(Charsets.UTF_8))
update(moduleName.toByteArray(Charsets.UTF_8))
update(verName.toByteArray(Charsets.UTF_8))
update(verCode.toString().toByteArray(Charsets.UTF_8))
update(author.toByteArray(Charsets.UTF_8))
update(description.toByteArray(Charsets.UTF_8))
digest().toHexString()
}
}

val androidMinSdkVersion by extra(31)
val androidTargetSdkVersion by extra(34)
val androidCompileSdkVersion by extra(34)
Expand Down
19 changes: 13 additions & 6 deletions module/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ dependencies {
implementation(libs.cxx)
}

androidComponents.onVariants { variant ->
afterEvaluate {
evaluationDependsOn(":service")

afterEvaluate {
android.applicationVariants.forEach { variant ->
val variantLowered = variant.name.lowercase()
val variantCapped = variant.name.capitalizeUS()
val buildTypeLowered = variant.buildType?.lowercase()
val buildTypeCapped = variant.buildType.name.replaceFirstChar { it.uppercase() }
val buildTypeLowered = variant.buildType.name.lowercase()
val supportedAbis = abiList.map {
when (it) {
"arm64-v8a" -> "arm64"
Expand All @@ -81,7 +84,10 @@ androidComponents.onVariants { variant ->

val prepareModuleFilesTask = task<Sync>("prepareModuleFiles$variantCapped") {
group = "module"
dependsOn("assemble$variantCapped", ":service:assemble$variantCapped")
dependsOn(
"assemble$variantCapped",
":service:package$buildTypeCapped"
)
into(moduleDir)
from(rootProject.layout.projectDirectory.file("README.md"))
from(layout.projectDirectory.file("template")) {
Expand Down Expand Up @@ -110,8 +116,9 @@ androidComponents.onVariants { variant ->
filter<ReplaceTokens>("tokens" to tokens)
filter<FixCrLfFilter>("eol" to FixCrLfFilter.CrLf.newInstance("lf"))
}
from(project(":service").layout.buildDirectory.file("outputs/apk/$variantLowered/service-$variantLowered.apk")) {
rename { "service.apk" }
from(project(":service").tasks.getByName("package$buildTypeCapped").outputs) {
include("*.apk")
rename(".*\\.apk", "service.apk")
}
from(layout.buildDirectory.file("intermediates/stripped_native_libs/$variantLowered/strip${variantCapped}DebugSymbols/out/lib")) {
exclude("**/libbinder.so", "**/libutils.so")
Expand Down
4 changes: 2 additions & 2 deletions service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ dependencies {
implementation(libs.bcpkix.jdk18on)
}

androidComponents.onVariants { variant ->
afterEvaluate {
afterEvaluate {
android.applicationVariants.forEach { variant ->
val variantLowered = variant.name.lowercase()
val variantCapped = variant.name.capitalizeUS()
val pushTask = task<Task>("pushService$variantCapped") {
Expand Down
4 changes: 1 addition & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ dependencyResolutionManagement {
}

rootProject.name = "TrickyStore"
include(
":module"
)
include(":module")
include(":service")
include(":stub")

0 comments on commit 3a515c5

Please sign in to comment.