gkd/app/build.gradle.kts

229 lines
7.2 KiB
Plaintext
Raw Normal View History

2023-07-10 11:25:17 +08:00
import com.android.build.gradle.internal.cxx.json.jsonStringOf
2024-01-17 11:38:04 +08:00
import java.io.ByteArrayOutputStream
fun String.runCommand(currentWorkingDir: File = file("./")): String {
val byteOut = ByteArrayOutputStream()
project.exec {
workingDir = currentWorkingDir
commandLine = this@runCommand.split("\\s".toRegex())
standardOutput = byteOut
2024-01-20 13:33:59 +08:00
errorOutput = ByteArrayOutputStream()
2024-01-17 11:38:04 +08:00
}
return String(byteOut.toByteArray()).trim()
}
2024-01-20 13:33:59 +08:00
data class GitInfo(
val commitId: String,
val tagName: String?,
)
val gitInfo = try {
GitInfo(
commitId = "git rev-parse HEAD".runCommand(),
tagName = try {
"git describe --tags --exact-match".runCommand()
} catch (e: Exception) {
println("app: current git commit is not a tag")
null
},
)
2024-01-17 11:38:04 +08:00
} catch (e: Exception) {
2024-01-20 13:33:59 +08:00
println("app: git is not available")
2024-01-17 11:38:04 +08:00
null
}
2023-07-10 11:25:17 +08:00
2024-01-20 13:33:59 +08:00
val vnSuffix = "-${gitInfo?.commitId?.substring(0, 7) ?: "unknown"}"
2021-11-19 14:08:52 +08:00
plugins {
2023-08-31 22:22:03 +08:00
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.google.ksp)
alias(libs.plugins.google.hilt)
alias(libs.plugins.rikka.refine)
2021-11-19 14:08:52 +08:00
}
android {
2023-05-18 15:34:49 +08:00
namespace = "li.songe.gkd"
2024-03-25 19:18:22 +08:00
compileSdk = libs.versions.compileSdk.get().toInt()
buildToolsVersion = libs.versions.buildToolsVersion.get()
2021-11-19 14:08:52 +08:00
defaultConfig {
2024-03-25 19:18:22 +08:00
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
2023-04-30 17:50:55 +08:00
2021-12-14 11:34:20 +08:00
applicationId = "li.songe.gkd"
2024-03-24 15:29:06 +08:00
versionCode = 27
versionName = "1.7.2"
2021-11-19 14:08:52 +08:00
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
2022-10-09 10:51:27 +08:00
2023-07-10 11:25:17 +08:00
val nowTime = System.currentTimeMillis()
buildConfigField("Long", "BUILD_TIME", jsonStringOf(nowTime) + "L")
2023-09-02 21:36:09 +08:00
buildConfigField(
2024-01-17 11:38:04 +08:00
"String",
"GIT_COMMIT_ID",
2024-01-20 13:33:59 +08:00
jsonStringOf(gitInfo?.commitId)
2023-09-02 21:36:09 +08:00
)
resourceConfigurations.addAll(listOf("zh", "en"))
ndk {
// noinspection ChromeOsAbiSupport
abiFilters += listOf("arm64-v8a", "x86_64")
}
2021-11-19 14:08:52 +08:00
}
2021-11-19 14:28:49 +08:00
2023-04-30 19:15:26 +08:00
lint {
disable.add("ModifierFactoryUnreferencedReceiver")
}
2023-11-29 14:59:41 +08:00
val currentSigning = if (project.hasProperty("GKD_STORE_FILE")) {
signingConfigs.create("release") {
storeFile = file(project.properties["GKD_STORE_FILE"] as String)
storePassword = project.properties["GKD_STORE_PASSWORD"] as String
keyAlias = project.properties["GKD_KEY_ALIAS"] as String
keyPassword = project.properties["GKD_KEY_PASSWORD"] as String
2021-11-19 14:28:49 +08:00
}
2023-11-29 14:59:41 +08:00
} else {
signingConfigs.getByName("debug")
2021-11-19 14:28:49 +08:00
}
2021-11-19 14:08:52 +08:00
buildTypes {
2023-11-29 14:59:41 +08:00
all {
signingConfig = currentSigning
}
2021-11-19 14:28:49 +08:00
release {
2024-01-20 13:33:59 +08:00
if (gitInfo?.tagName == null) {
versionNameSuffix = vnSuffix
}
2023-11-22 17:16:37 +08:00
isMinifyEnabled = true
isShrinkResources = true
2021-11-19 14:28:49 +08:00
setProguardFiles(
listOf(
2023-11-22 17:16:37 +08:00
// /sdk/tools/proguard/proguard-android-optimize.txt
2023-09-02 21:36:09 +08:00
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
2021-11-19 14:28:49 +08:00
)
)
}
debug {
2024-01-20 13:33:59 +08:00
versionNameSuffix = vnSuffix
2023-09-02 21:36:09 +08:00
applicationIdSuffix = ".debug"
2023-11-22 17:16:37 +08:00
resValue("string", "app_name", "GKD-debug")
2024-03-03 01:36:50 +08:00
resValue("string", "capture_label", "捕获快照-debug")
2021-11-19 14:08:52 +08:00
}
}
compileOptions {
2023-07-10 11:25:17 +08:00
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
2022-10-09 10:51:27 +08:00
2021-11-19 14:08:52 +08:00
}
kotlinOptions {
2023-07-10 11:25:17 +08:00
jvmTarget = JavaVersion.VERSION_17.majorVersion
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
2023-11-25 00:16:41 +08:00
freeCompilerArgs += "-opt-in=kotlinx.coroutines.FlowPreview"
2023-10-24 17:26:07 +08:00
freeCompilerArgs += "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api"
freeCompilerArgs += "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi"
2021-11-19 14:08:52 +08:00
}
buildFeatures {
2023-05-18 15:34:49 +08:00
buildConfig = true
2021-11-19 14:28:49 +08:00
compose = true
2024-03-15 20:54:20 +08:00
aidl = true
2021-11-19 14:08:52 +08:00
}
composeOptions {
2024-03-25 19:18:22 +08:00
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
2021-11-19 14:08:52 +08:00
}
2023-11-22 17:16:37 +08:00
packagingOptions.resources.excludes += setOf(
// https://github.com/Kotlin/kotlinx.coroutines/issues/2023
"META-INF/**", "**/attach_hotspot_windows.dll",
"**.properties", "**.bin", "**/*.proto"
)
configurations.configureEach {
// https://github.com/Kotlin/kotlinx.coroutines/issues/2023
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-debug")
2021-11-19 14:08:52 +08:00
}
2023-07-10 11:25:17 +08:00
2023-11-22 17:16:37 +08:00
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("room.incremental", "true")
2023-12-29 20:13:45 +08:00
arg("room.generateKotlin", "true")
2023-11-22 17:16:37 +08:00
}
2023-07-10 11:25:17 +08:00
sourceSets.configureEach {
2023-12-29 20:13:45 +08:00
kotlin.srcDir("${layout.buildDirectory.asFile.get()}/generated/ksp/$name/kotlin/")
2023-07-10 11:25:17 +08:00
}
2021-11-19 14:08:52 +08:00
}
dependencies {
2022-12-09 22:39:24 +08:00
2023-07-10 11:25:17 +08:00
implementation(project(mapOf("path" to ":selector")))
2023-04-30 17:50:55 +08:00
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.compose.ui)
implementation(libs.compose.material3)
2023-12-31 01:08:25 +08:00
implementation(libs.compose.icons)
2023-04-30 17:50:55 +08:00
implementation(libs.compose.preview)
debugImplementation(libs.compose.tooling)
androidTestImplementation(libs.compose.junit4)
implementation(libs.compose.activity)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso)
2023-07-10 11:25:17 +08:00
compileOnly(project(mapOf("path" to ":hidden_api")))
2023-04-30 17:50:55 +08:00
implementation(libs.rikka.shizuku.api)
implementation(libs.rikka.shizuku.provider)
2023-07-10 11:25:17 +08:00
implementation(libs.lsposed.hiddenapibypass)
2023-04-30 17:50:55 +08:00
implementation(libs.tencent.mmkv)
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
2024-02-22 22:34:21 +08:00
implementation(libs.androidx.room.paging)
2023-07-10 11:25:17 +08:00
ksp(libs.androidx.room.compiler)
2023-04-30 17:50:55 +08:00
2024-02-22 22:34:21 +08:00
implementation(libs.androidx.paging.runtime)
implementation(libs.androidx.paging.compose)
2023-04-30 17:50:55 +08:00
implementation(libs.ktor.server.core)
2023-11-22 17:16:37 +08:00
implementation(libs.ktor.server.cio)
2023-04-30 17:50:55 +08:00
implementation(libs.ktor.server.content.negotiation)
implementation(libs.ktor.client.core)
2023-08-31 22:22:03 +08:00
implementation(libs.ktor.client.okhttp)
2023-04-30 17:50:55 +08:00
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
implementation(libs.google.accompanist.drawablepainter)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.others.jankson)
implementation(libs.others.utilcodex)
implementation(libs.others.activityResultLauncher)
implementation(libs.others.floating.bubble.view)
2023-04-28 18:21:28 +08:00
2023-07-10 11:25:17 +08:00
implementation(libs.destinations.core)
ksp(libs.destinations.ksp)
2023-08-10 22:02:12 +08:00
implementation(libs.google.hilt.android)
2023-11-27 11:56:22 +08:00
ksp(libs.google.hilt.android.compiler)
2023-08-10 22:02:12 +08:00
implementation(libs.androidx.hilt.navigation.compose)
2023-08-31 22:22:03 +08:00
implementation(libs.others.reorderable)
implementation(libs.androidx.splashscreen)
implementation(libs.coil.compose)
implementation(libs.coil.gif)
2024-02-18 02:03:15 +08:00
implementation(libs.exp4j)
2024-02-27 22:05:25 +08:00
implementation(libs.toaster)
2021-11-19 14:08:52 +08:00
}