2022-08-15 21:50:55 -04:00
|
|
|
@file:Suppress("UnstableApiUsage")
|
|
|
|
|
|
2025-07-07 22:37:43 -07:00
|
|
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
|
|
|
|
|
|
|
|
|
2021-07-17 00:26:04 +02:00
|
|
|
plugins {
|
2024-01-12 14:27:54 -08:00
|
|
|
alias(libs.plugins.android.application)
|
2025-01-13 17:25:28 -08:00
|
|
|
alias(libs.plugins.compose.compiler)
|
2024-01-12 14:27:54 -08:00
|
|
|
alias(libs.plugins.kotlin.android)
|
|
|
|
|
alias(libs.plugins.kotlin.parcelize)
|
|
|
|
|
alias(libs.plugins.kotlin.serialization)
|
2021-07-17 00:26:04 +02:00
|
|
|
}
|
|
|
|
|
|
2025-06-20 22:58:44 -07:00
|
|
|
val isRelease = System.getenv("RELEASE")?.toBoolean() ?: false
|
2025-05-25 13:48:08 -07:00
|
|
|
val gitCurrentBranch = providers.execIgnoreCode("git", "symbolic-ref", "--quiet", "--short", "HEAD").takeIf { it.isNotEmpty() }
|
2025-01-13 17:27:18 -08:00
|
|
|
val gitLatestCommit = providers.execIgnoreCode("git", "rev-parse", "--short", "HEAD")
|
2025-05-25 13:48:08 -07:00
|
|
|
val gitHasLocalCommits = gitCurrentBranch?.let { providers.execIgnoreCode("git", "log", "origin/$gitCurrentBranch..HEAD").isNotEmpty() } ?: false
|
2025-01-13 17:27:18 -08:00
|
|
|
val gitHasHasLocalChanges = providers.execIgnoreCode("git", "status", "-s").isNotEmpty()
|
|
|
|
|
|
2021-07-17 00:26:04 +02:00
|
|
|
android {
|
2025-07-14 19:08:44 +08:00
|
|
|
namespace = "dev.wintry.manager"
|
2025-05-17 12:14:06 -07:00
|
|
|
compileSdk = 36
|
2021-07-17 00:26:04 +02:00
|
|
|
|
|
|
|
|
defaultConfig {
|
2025-07-13 23:02:58 +08:00
|
|
|
minSdk = 28
|
2025-05-17 12:14:06 -07:00
|
|
|
targetSdk = 36
|
2025-07-14 20:31:43 +08:00
|
|
|
versionCode = 10_00_00
|
|
|
|
|
versionName = "1.0.0"
|
2021-07-17 00:26:04 +02:00
|
|
|
|
2022-12-14 19:21:40 -08:00
|
|
|
vectorDrawables {
|
|
|
|
|
useSupportLibrary = true
|
|
|
|
|
}
|
2021-07-17 00:26:04 +02:00
|
|
|
|
2025-07-14 19:08:44 +08:00
|
|
|
buildConfigField("String", "APPLICATION_NAME", "\"Wintry Manager\"")
|
|
|
|
|
buildConfigField("String", "TAG", "\"WintryManager\"")
|
2025-07-14 20:00:38 +08:00
|
|
|
|
2025-07-14 20:31:43 +08:00
|
|
|
buildConfigField("String", "GITHUB_ORG", "\"wtcord\"")
|
2025-07-14 20:00:38 +08:00
|
|
|
buildConfigField("String", "SUPPORT_SERVER", "\"ybPB5tgD\"")
|
2024-01-18 17:10:00 -08:00
|
|
|
|
|
|
|
|
buildConfigField("String", "BACKEND_URL", "\"https://aliucord.com/\"")
|
2022-10-23 07:47:00 -07:00
|
|
|
|
2025-06-20 22:58:44 -07:00
|
|
|
buildConfigField("Boolean", "RELEASE", isRelease.toString())
|
2025-01-13 17:27:18 -08:00
|
|
|
buildConfigField("String", "GIT_BRANCH", "\"$gitCurrentBranch\"")
|
|
|
|
|
buildConfigField("String", "GIT_COMMIT", "\"$gitLatestCommit\"")
|
|
|
|
|
buildConfigField("boolean", "GIT_LOCAL_COMMITS", "$gitHasLocalCommits")
|
|
|
|
|
buildConfigField("boolean", "GIT_LOCAL_CHANGES", "$gitHasHasLocalChanges")
|
2021-07-17 00:26:04 +02:00
|
|
|
}
|
|
|
|
|
|
2022-12-20 15:40:00 -08:00
|
|
|
signingConfigs {
|
|
|
|
|
create("release") {
|
|
|
|
|
enableV1Signing = true
|
|
|
|
|
enableV2Signing = true
|
|
|
|
|
enableV3Signing = true
|
|
|
|
|
enableV4Signing = true
|
|
|
|
|
keyAlias = System.getenv("SIGNING_KEY_ALIAS")
|
|
|
|
|
keyPassword = System.getenv("SIGNING_KEY_PASSWORD")
|
2025-05-18 13:54:04 -07:00
|
|
|
storeFile = System.getenv("SIGNING_STORE_FILE")?.let(::File)
|
2022-12-20 15:40:00 -08:00
|
|
|
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-17 00:26:04 +02:00
|
|
|
buildTypes {
|
2025-06-20 20:20:05 -07:00
|
|
|
val isRelease = System.getenv("RELEASE")?.toBoolean() ?: false
|
2025-02-07 17:08:30 -08:00
|
|
|
val hasReleaseSigning = System.getenv("SIGNING_STORE_PASSWORD")?.isNotEmpty() == true
|
|
|
|
|
|
2025-06-20 20:20:05 -07:00
|
|
|
if (isRelease && !hasReleaseSigning)
|
|
|
|
|
error("Missing keystore in a release workflow!")
|
|
|
|
|
|
2021-07-17 00:26:04 +02:00
|
|
|
release {
|
|
|
|
|
isMinifyEnabled = true
|
2022-08-15 00:25:40 -04:00
|
|
|
isShrinkResources = true
|
2022-12-20 15:40:00 -08:00
|
|
|
isCrunchPngs = true
|
2025-02-07 17:08:30 -08:00
|
|
|
signingConfig = signingConfigs.getByName(if (hasReleaseSigning) "release" else "debug")
|
2021-07-17 00:26:04 +02:00
|
|
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
|
|
|
|
}
|
2025-05-18 13:54:04 -07:00
|
|
|
|
|
|
|
|
create("staging") {
|
|
|
|
|
isMinifyEnabled = true
|
|
|
|
|
isShrinkResources = true
|
|
|
|
|
isCrunchPngs = true
|
|
|
|
|
signingConfig = signingConfigs.getByName("debug")
|
2025-07-05 11:59:35 -07:00
|
|
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
2025-05-18 13:54:04 -07:00
|
|
|
}
|
2021-07-17 00:26:04 +02:00
|
|
|
}
|
2022-02-17 18:25:22 -05:00
|
|
|
|
2022-09-18 12:42:27 -07:00
|
|
|
androidComponents {
|
|
|
|
|
onVariants(selector().withBuildType("release")) {
|
|
|
|
|
it.packaging.resources.excludes.apply {
|
|
|
|
|
// Debug metadata
|
|
|
|
|
add("/**/*.version")
|
|
|
|
|
add("/kotlin-tooling-metadata.json")
|
|
|
|
|
// Kotlin debugging (https://github.com/Kotlin/kotlinx.coroutines/issues/2274)
|
|
|
|
|
add("/DebugProbesKt.bin")
|
2025-03-22 23:26:53 -07:00
|
|
|
// Reflection symbol list (https://stackoverflow.com/a/41073782/13964629)
|
|
|
|
|
add("/**/*.kotlin_builtins")
|
2022-09-18 12:42:27 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-12 14:27:54 -08:00
|
|
|
packaging {
|
2022-09-18 12:42:27 -07:00
|
|
|
resources {
|
|
|
|
|
// okhttp3 is used by some lib (no cookies so publicsuffixes.gz can be dropped)
|
|
|
|
|
excludes += "/okhttp3/**"
|
2025-01-13 17:22:48 -08:00
|
|
|
|
|
|
|
|
// Remnants of smali/baksmali lib
|
|
|
|
|
excludes += "/*.properties"
|
|
|
|
|
excludes += "/org/antlr/**"
|
|
|
|
|
excludes += "/com/android/tools/smali/**"
|
|
|
|
|
excludes += "/org/eclipse/jgit/**"
|
|
|
|
|
|
2025-02-07 15:35:39 -08:00
|
|
|
// bouncycastle
|
|
|
|
|
excludes += "/META-INF/versions/9/OSGI-INF/MANIFEST.MF"
|
2025-01-13 17:22:48 -08:00
|
|
|
excludes += "/org/bouncycastle/**"
|
2022-09-18 12:42:27 -07:00
|
|
|
}
|
2024-03-03 21:08:25 -08:00
|
|
|
jniLibs {
|
|
|
|
|
// x86 is dead
|
|
|
|
|
excludes += "/lib/x86/*.so"
|
2025-03-03 20:16:01 -08:00
|
|
|
|
|
|
|
|
// Equivalent of AndroidManifest's extractNativeLibs=false
|
|
|
|
|
useLegacyPackaging = false
|
2024-03-03 21:08:25 -08:00
|
|
|
}
|
2022-09-18 12:42:27 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-17 00:26:04 +02:00
|
|
|
compileOptions {
|
2025-05-17 11:38:02 -07:00
|
|
|
isCoreLibraryDesugaringEnabled = true
|
|
|
|
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
|
|
|
targetCompatibility = JavaVersion.VERSION_1_8
|
2021-07-17 00:26:04 +02:00
|
|
|
}
|
2022-02-17 18:25:22 -05:00
|
|
|
|
2022-12-14 19:21:40 -08:00
|
|
|
buildFeatures {
|
2024-01-12 14:27:54 -08:00
|
|
|
buildConfig = true
|
2022-12-14 19:21:40 -08:00
|
|
|
compose = true
|
2021-07-17 00:26:04 +02:00
|
|
|
}
|
2022-02-17 18:25:22 -05:00
|
|
|
|
2024-02-07 10:49:27 -08:00
|
|
|
lint {
|
|
|
|
|
disable += "ModifierParameter"
|
|
|
|
|
}
|
2022-03-05 15:45:46 -05:00
|
|
|
}
|
|
|
|
|
|
2025-01-24 15:41:59 -08:00
|
|
|
kotlin {
|
|
|
|
|
sourceSets.all {
|
|
|
|
|
languageSettings.enableLanguageFeature("ExplicitBackingFields")
|
2025-07-07 22:37:43 -07:00
|
|
|
}
|
|
|
|
|
compilerOptions {
|
|
|
|
|
val reportsDir = layout.buildDirectory.asFile.get()
|
|
|
|
|
.resolve("reports").absolutePath
|
|
|
|
|
|
|
|
|
|
jvmTarget = JvmTarget.JVM_1_8
|
|
|
|
|
freeCompilerArgs.addAll(
|
|
|
|
|
"-opt-in=kotlin.time.ExperimentalTime",
|
|
|
|
|
"-opt-in=androidx.compose.material3.ExperimentalMaterial3Api",
|
|
|
|
|
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
|
|
|
|
|
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
|
|
|
|
|
"-opt-in=androidx.compose.foundation.layout.ExperimentalLayoutApi",
|
|
|
|
|
"-P", "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${reportsDir}",
|
|
|
|
|
"-XXLanguage:+PropertyParamAnnotationDefaultTargetMode", // @StringRes in field parameters of a class warning
|
|
|
|
|
)
|
2025-01-24 15:41:59 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-18 13:54:04 -07:00
|
|
|
tasks.withType<JavaCompile> {
|
|
|
|
|
// Disable warnings about obsolete target version
|
|
|
|
|
options.compilerArgs.add("-Xlint:-options")
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-17 00:26:04 +02:00
|
|
|
dependencies {
|
2024-01-12 14:27:54 -08:00
|
|
|
implementation(libs.bundles.accompanist)
|
|
|
|
|
implementation(libs.bundles.androidx)
|
2025-01-13 17:25:28 -08:00
|
|
|
implementation(libs.bundles.coil)
|
2024-01-12 14:27:54 -08:00
|
|
|
implementation(libs.bundles.compose)
|
|
|
|
|
implementation(libs.bundles.koin)
|
|
|
|
|
implementation(libs.bundles.ktor)
|
2024-01-13 13:01:08 -08:00
|
|
|
implementation(libs.bundles.voyager)
|
2024-01-12 14:27:54 -08:00
|
|
|
|
2025-07-13 23:02:58 +08:00
|
|
|
implementation(files("libs/lspatch.aar"))
|
|
|
|
|
|
2024-01-12 14:27:54 -08:00
|
|
|
implementation(libs.compose.ui.tooling.preview)
|
|
|
|
|
debugImplementation(libs.compose.ui.tooling)
|
|
|
|
|
debugImplementation(libs.compose.runtime.tracing)
|
|
|
|
|
|
|
|
|
|
implementation(libs.kotlinx.immutable)
|
2025-04-06 21:26:31 -07:00
|
|
|
implementation(libs.kotlinx.serialization.json)
|
2024-01-12 14:27:54 -08:00
|
|
|
|
|
|
|
|
implementation(libs.apksig)
|
|
|
|
|
implementation(libs.axml)
|
|
|
|
|
implementation(libs.bouncycastle)
|
2024-03-15 16:26:58 -07:00
|
|
|
implementation(libs.binaryResources)
|
2024-12-22 14:35:47 -08:00
|
|
|
implementation(libs.diff)
|
2024-05-16 10:57:11 -07:00
|
|
|
implementation(libs.microg)
|
2024-12-22 14:35:47 -08:00
|
|
|
implementation(libs.smali)
|
|
|
|
|
implementation(libs.baksmali)
|
2025-03-29 15:15:41 -07:00
|
|
|
implementation(libs.compose.pipette)
|
2025-01-14 22:24:52 -08:00
|
|
|
implementation(libs.compose.shimmer)
|
2025-07-07 22:37:43 -07:00
|
|
|
implementation(libs.zip)
|
2025-05-17 11:38:02 -07:00
|
|
|
|
2025-07-07 22:37:43 -07:00
|
|
|
coreLibraryDesugaring(libs.desugaring)
|
2022-03-12 22:30:38 +01:00
|
|
|
}
|
2022-10-23 07:47:00 -07:00
|
|
|
|
2025-07-13 23:02:58 +08:00
|
|
|
configurations.all {
|
|
|
|
|
exclude(group = "org.bouncycastle")
|
|
|
|
|
exclude(group = "org.checkerframework", module = "checker-qual")
|
|
|
|
|
exclude(group = "com.aliucord", module = "axml")
|
|
|
|
|
|
|
|
|
|
// Exclude apksig, as it's bundled in LSPatch
|
|
|
|
|
exclude(group = "com.android.tools.build", module = "apksig")
|
|
|
|
|
|
|
|
|
|
// Exclude jcommander
|
|
|
|
|
exclude(group = "com.beust", module = "jcommander")
|
|
|
|
|
|
|
|
|
|
// Exclude Google Guava and its related modules
|
|
|
|
|
exclude(group = "com.google.guava")
|
|
|
|
|
|
|
|
|
|
// Exclude other common utility/annotation libraries
|
|
|
|
|
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
|
|
|
|
|
exclude(group = "com.google.j2objc", module = "j2objc-annotations")
|
|
|
|
|
exclude(group = "com.google.code.findbugs", module = "jsr305")
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-13 17:27:18 -08:00
|
|
|
fun ProviderFactory.execIgnoreCode(vararg command: String): String = run {
|
|
|
|
|
val result = exec {
|
|
|
|
|
commandLine = command.toList()
|
|
|
|
|
isIgnoreExitValue = true
|
|
|
|
|
}
|
2022-10-23 07:47:00 -07:00
|
|
|
|
2025-01-13 17:27:18 -08:00
|
|
|
val stderr = result.standardError.asText.get()
|
|
|
|
|
if (stderr.isNotEmpty())
|
|
|
|
|
throw RuntimeException(stderr)
|
2022-10-23 07:47:00 -07:00
|
|
|
|
2025-01-13 17:27:18 -08:00
|
|
|
result.standardOutput.asText.get().trim()
|
2022-10-23 07:47:00 -07:00
|
|
|
}
|