GoonManager/app/build.gradle.kts

235 lines
8.1 KiB
Text
Raw Normal View History

2022-08-15 21:50:55 -04:00
@file:Suppress("UnstableApiUsage")
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2021-07-17 00:26:04 +02:00
plugins {
alias(libs.plugins.android.application)
2025-01-13 17:25:28 -08:00
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.hiddenApi.refine)
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() }
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
val gitHasHasLocalChanges = providers.execIgnoreCode("git", "status", "-s").isNotEmpty()
2021-07-17 00:26:04 +02:00
android {
namespace = "dev.shiggy.manager"
2026-05-07 16:02:23 +02:00
compileSdk = 37
2021-07-17 00:26:04 +02:00
defaultConfig {
minSdk = 28
2026-05-07 16:02:23 +02:00
targetSdk = 37
2026-06-09 11:27:20 +00:00
versionCode = 10_12_01
2026-05-07 16:02:23 +02:00
versionName = "1.1.2"
2022-12-14 19:21:40 -08:00
vectorDrawables {
useSupportLibrary = true
}
2021-07-17 00:26:04 +02:00
buildConfigField("String", "APPLICATION_NAME", "\"Shiggy Manager\"")
buildConfigField("String", "TAG", "\"ShiggyManager\"")
buildConfigField("String", "GITHUB_ORG", "\"ShiggyCord\"")
buildConfigField("String", "SUPPORT_SERVER", "\"\"")
2024-01-18 17:10:00 -08:00
buildConfigField("String", "BACKEND_URL", "\"https://aliucord.com/\"")
2025-06-20 22:58:44 -07:00
buildConfigField("Boolean", "RELEASE", isRelease.toString())
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
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
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")
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
}
}
}
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"
// 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 {
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 {
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
}
kotlin {
sourceSets.all {
languageSettings.enableLanguageFeature("ExplicitBackingFields")
}
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-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 {
implementation(libs.bundles.accompanist)
implementation(libs.bundles.androidx)
2025-01-13 17:25:28 -08:00
implementation(libs.bundles.coil)
implementation(libs.bundles.compose)
implementation(libs.bundles.koin)
implementation(libs.bundles.ktor)
implementation(libs.bundles.voyager)
implementation(files("libs/lspatch.aar"))
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)
implementation(libs.apksig)
implementation(libs.axml)
implementation(libs.bouncycastle)
2024-03-15 16:26:58 -07:00
implementation(libs.binaryResources)
implementation(libs.diff)
2024-05-16 10:57:11 -07:00
implementation(libs.microg)
implementation(libs.bundles.shizuku)
implementation(libs.smali)
implementation(libs.baksmali)
2025-03-29 15:15:41 -07:00
implementation(libs.compose.pipette)
implementation(libs.compose.shimmer)
implementation(libs.zip)
compileOnly(libs.hiddenApi.stub)
implementation(libs.hiddenApi.refine)
implementation(libs.hiddenApi.bypass)
coreLibraryDesugaring(libs.desugaring)
2022-03-12 22:30:38 +01: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")
}
fun ProviderFactory.execIgnoreCode(vararg command: String): String = run {
val result = exec {
commandLine = command.toList()
isIgnoreExitValue = true
}
val stderr = result.standardError.asText.get()
if (stderr.isNotEmpty())
throw RuntimeException(stderr)
result.standardOutput.asText.get().trim()
}