GoonManager/app/build.gradle.kts

164 lines
4.8 KiB
Text
Raw Normal View History

2022-08-15 21:50:55 -04:00
@file:Suppress("UnstableApiUsage")
import java.io.ByteArrayOutputStream
2021-07-17 00:26:04 +02:00
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.serialization)
2021-07-17 00:26:04 +02:00
}
android {
2022-08-02 16:28:06 -04:00
namespace = "com.aliucord.manager"
compileSdk = 34
2021-07-17 00:26:04 +02:00
defaultConfig {
minSdk = 24
targetSdk = 34
2021-07-17 00:26:04 +02:00
versionCode = 1
versionName = "0.0.1"
2022-12-14 19:21:40 -08:00
vectorDrawables {
useSupportLibrary = true
}
2021-07-17 00:26:04 +02:00
buildConfigField("String", "TAG", "\"AliucordManager\"")
buildConfigField("String", "SUPPORT_SERVER", "\"EsNDvBaHVU\"")
2022-10-30 08:44:58 -07:00
buildConfigField("boolean", "RN_ENABLED", "true")
buildConfigField("String", "GIT_BRANCH", "\"${getCurrentBranch()}\"")
buildConfigField("String", "GIT_COMMIT", "\"${getLatestCommit()}\"")
buildConfigField("boolean", "GIT_LOCAL_COMMITS", "${gitHasLocalCommits()}")
buildConfigField("boolean", "GIT_LOCAL_CHANGES", "${gitHasLocalChanges()}")
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")
storeFile = System.getenv("SIGNING_STORE_FILE")?.let { File(it) }
storePassword = System.getenv("SIGNING_STORE_PASSWORD")
}
}
2021-07-17 00:26:04 +02:00
buildTypes {
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("release")
2021-07-17 00:26:04 +02:00
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
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")
}
}
}
packaging {
2022-09-18 12:42:27 -07:00
resources {
// Reflection symbol list (https://stackoverflow.com/a/41073782/13964629)
excludes += "/**/*.kotlin_builtins"
// okhttp3 is used by some lib (no cookies so publicsuffixes.gz can be dropped)
excludes += "/okhttp3/**"
}
}
2021-07-17 00:26:04 +02:00
compileOptions {
2022-02-17 18:25:22 -05:00
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
2021-07-17 00:26:04 +02:00
}
2022-02-17 18:25:22 -05:00
2021-07-17 00:26:04 +02:00
kotlinOptions {
val reportsDir = layout.buildDirectory.asFile.get()
.resolve("reports").absolutePath
2022-02-17 18:25:22 -05:00
jvmTarget = "11"
2022-12-14 19:21:40 -08:00
freeCompilerArgs += listOf(
"-Xcontext-receivers",
"-P", "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${reportsDir}",
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
2022-12-14 19:21:40 -08:00
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
2022-12-14 19:21:40 -08:00
}
2022-03-05 15:45:46 -05:00
}
2021-07-17 00:26:04 +02:00
dependencies {
implementation(libs.bundles.accompanist)
implementation(libs.bundles.androidx)
implementation(libs.bundles.compose)
implementation(libs.bundles.koin)
implementation(libs.bundles.ktor)
implementation(libs.compose.ui.tooling.preview)
debugImplementation(libs.compose.ui.tooling)
debugImplementation(libs.compose.runtime.tracing)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.immutable)
implementation(libs.apksig)
implementation(libs.axml)
implementation(libs.bouncycastle)
implementation(libs.coil)
implementation(libs.navigationReimagined)
implementation(variantOf(libs.zip) { artifactType("aar") })
2022-03-12 22:30:38 +01:00
}
fun getCurrentBranch(): String? =
exec("git", "symbolic-ref", "--short", "HEAD")
fun getLatestCommit(): String? =
exec("git", "rev-parse", "--short", "HEAD")
fun gitHasLocalCommits(): Boolean {
val branch = getCurrentBranch() ?: return false
return exec("git", "log", "origin/$branch..HEAD")?.isNotEmpty() ?: false
}
fun gitHasLocalChanges(): Boolean =
exec("git", "status", "-s")?.isNotEmpty() ?: false
fun exec(vararg command: String): String? {
return try {
val stdout = ByteArrayOutputStream()
val errout = ByteArrayOutputStream()
exec {
commandLine = command.toList()
standardOutput = stdout
errorOutput = errout
isIgnoreExitValue = true
}
if (errout.size() > 0)
throw Error(errout.toString(Charsets.UTF_8))
stdout.toString(Charsets.UTF_8).trim()
} catch (t: Throwable) {
t.printStackTrace()
null
}
}