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,
|
2024-10-22 21:57:33 +08:00
|
|
|
val commitTime: String,
|
2024-01-20 13:33:59 +08:00
|
|
|
val tagName: String?,
|
|
|
|
)
|
|
|
|
|
|
|
|
val gitInfo = try {
|
|
|
|
GitInfo(
|
|
|
|
commitId = "git rev-parse HEAD".runCommand(),
|
2024-10-22 21:57:33 +08:00
|
|
|
commitTime = "git log -1 --format=%ct".runCommand(),
|
2024-01-20 13:33:59 +08:00
|
|
|
tagName = try {
|
|
|
|
"git describe --tags --exact-match".runCommand()
|
2024-10-22 21:57:33 +08:00
|
|
|
} catch (_: Exception) {
|
2024-01-20 13:33:59 +08:00
|
|
|
println("app: current git commit is not a tag")
|
|
|
|
null
|
|
|
|
},
|
|
|
|
)
|
2024-10-22 21:57:33 +08:00
|
|
|
} catch (_: 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-10-22 21:57:33 +08:00
|
|
|
println("app: $gitInfo")
|
|
|
|
|
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)
|
2024-07-16 20:29:47 +08:00
|
|
|
alias(libs.plugins.androidx.room)
|
2023-08-31 22:22:03 +08:00
|
|
|
alias(libs.plugins.kotlin.android)
|
|
|
|
alias(libs.plugins.kotlin.parcelize)
|
|
|
|
alias(libs.plugins.kotlin.serialization)
|
2024-05-22 20:10:44 +08:00
|
|
|
alias(libs.plugins.kotlin.compose)
|
2023-08-31 22:22:03 +08:00
|
|
|
alias(libs.plugins.google.ksp)
|
|
|
|
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-08-08 21:10:55 +08:00
|
|
|
compileSdk = project.properties["android_compileSdk"].toString().toInt()
|
|
|
|
buildToolsVersion = project.properties["android_buildToolsVersion"].toString()
|
2021-11-19 14:08:52 +08:00
|
|
|
|
|
|
|
defaultConfig {
|
2024-08-08 21:10:55 +08:00
|
|
|
minSdk = project.properties["android_minSdk"].toString().toInt()
|
|
|
|
targetSdk = project.properties["android_targetSdk"].toString().toInt()
|
2023-04-30 17:50:55 +08:00
|
|
|
|
2021-12-14 11:34:20 +08:00
|
|
|
applicationId = "li.songe.gkd"
|
2024-11-11 17:02:33 +08:00
|
|
|
versionCode = 48
|
|
|
|
versionName = "v1.9.1"
|
2021-11-19 14:08:52 +08:00
|
|
|
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
vectorDrawables {
|
|
|
|
useSupportLibrary = true
|
|
|
|
}
|
2023-10-31 17:41:42 +08:00
|
|
|
resourceConfigurations.addAll(listOf("zh", "en"))
|
|
|
|
ndk {
|
|
|
|
// noinspection ChromeOsAbiSupport
|
|
|
|
abiFilters += listOf("arm64-v8a", "x86_64")
|
|
|
|
}
|
2024-09-09 21:17:03 +08:00
|
|
|
|
2024-10-22 21:57:33 +08:00
|
|
|
manifestPlaceholders["commitId"] = gitInfo?.commitId ?: "unknown"
|
|
|
|
manifestPlaceholders["commitTime"] = gitInfo?.commitTime?.let { it + "000" } ?: "0"
|
2021-11-19 14:08:52 +08:00
|
|
|
}
|
2021-11-19 14:28:49 +08:00
|
|
|
|
2024-07-08 22:10:36 +08:00
|
|
|
lint {}
|
2023-04-30 19:15:26 +08:00
|
|
|
|
2024-07-16 20:29:47 +08:00
|
|
|
buildFeatures {
|
|
|
|
compose = true
|
|
|
|
aidl = true
|
|
|
|
}
|
|
|
|
|
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
|
2024-09-09 21:17:03 +08:00
|
|
|
isDebuggable = false
|
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"
|
2024-09-28 15:35:26 +08:00
|
|
|
|
|
|
|
// add "debug" suffix
|
|
|
|
listOf(
|
|
|
|
"app_name" to "GKD",
|
|
|
|
"capture_snapshot" to "捕获快照",
|
|
|
|
"import_data" to "导入数据",
|
|
|
|
"http_server" to "HTTP服务",
|
2024-10-02 02:16:41 +08:00
|
|
|
"float_button" to "悬浮按钮",
|
2024-09-28 15:35:26 +08:00
|
|
|
).forEach {
|
|
|
|
resValue("string", it.first, it.second + "-debug")
|
|
|
|
}
|
2021-11-19 14:08:52 +08:00
|
|
|
}
|
|
|
|
}
|
2024-07-16 20:29:47 +08:00
|
|
|
productFlavors {
|
|
|
|
flavorDimensions += "channel"
|
2024-09-09 21:17:03 +08:00
|
|
|
create("gkd") {
|
2024-07-16 20:29:47 +08:00
|
|
|
isDefault = true
|
2024-09-09 21:17:03 +08:00
|
|
|
manifestPlaceholders["updateEnabled"] = true
|
2024-07-16 20:29:47 +08:00
|
|
|
}
|
2024-08-19 16:44:40 +08:00
|
|
|
create("foss") {
|
2024-09-09 21:17:03 +08:00
|
|
|
manifestPlaceholders["updateEnabled"] = false
|
2024-07-16 20:29:47 +08:00
|
|
|
}
|
|
|
|
all {
|
|
|
|
dimension = flavorDimensionList.first()
|
|
|
|
manifestPlaceholders["channel"] = name
|
|
|
|
}
|
|
|
|
}
|
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
|
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"
|
2024-07-08 22:10:36 +08:00
|
|
|
freeCompilerArgs += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
|
2024-08-08 21:10:55 +08:00
|
|
|
freeCompilerArgs += "-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
|
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
|
|
|
}
|
2024-07-16 20:29:47 +08:00
|
|
|
dependenciesInfo.includeInApk = false
|
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",
|
|
|
|
|
2024-05-10 21:00:58 +08:00
|
|
|
"**.properties", "**.bin", "**/*.proto",
|
|
|
|
"**/kotlin-tooling-metadata.json",
|
|
|
|
|
|
|
|
// ktor
|
|
|
|
"**/custom.config.conf",
|
|
|
|
"**/custom.config.yaml",
|
2023-11-22 17:16:37 +08:00
|
|
|
)
|
2021-11-19 14:08:52 +08:00
|
|
|
}
|
|
|
|
|
2024-07-16 20:29:47 +08:00
|
|
|
// https://developer.android.com/jetpack/androidx/releases/room?hl=zh-cn#compiler-options
|
|
|
|
room {
|
|
|
|
schemaDirectory("$projectDir/schemas")
|
2024-05-22 20:10:44 +08:00
|
|
|
}
|
|
|
|
ksp {
|
|
|
|
arg("room.generateKotlin", "true")
|
|
|
|
}
|
|
|
|
|
2024-07-16 20:29:47 +08:00
|
|
|
configurations.configureEach {
|
|
|
|
// https://github.com/Kotlin/kotlinx.coroutines/issues/2023
|
|
|
|
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-debug")
|
|
|
|
}
|
|
|
|
|
2024-05-22 20:10:44 +08:00
|
|
|
composeCompiler {
|
2024-09-13 18:09:27 +08:00
|
|
|
// featureFlags.addAll(ComposeFeatureFlag.StrongSkipping) // default StrongSkipping
|
2024-05-22 20:10:44 +08:00
|
|
|
reportsDestination = layout.buildDirectory.dir("compose_compiler")
|
|
|
|
stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
|
|
|
|
}
|
|
|
|
|
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")))
|
2024-08-13 22:38:49 +08:00
|
|
|
|
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)
|
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)
|
2024-10-05 00:42:53 +08:00
|
|
|
|
2023-04-30 17:50:55 +08:00
|
|
|
implementation(libs.compose.activity)
|
2024-10-05 00:42:53 +08:00
|
|
|
implementation(libs.compose.material3)
|
|
|
|
implementation(libs.compose.navigation)
|
2023-04-30 17:50:55 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2024-10-05 01:00:03 +08:00
|
|
|
implementation(libs.utilcodex)
|
|
|
|
implementation(libs.activityResultLauncher)
|
|
|
|
implementation(libs.floatingBubbleView)
|
2023-04-28 18:21:28 +08:00
|
|
|
|
2023-07-10 11:25:17 +08:00
|
|
|
implementation(libs.destinations.core)
|
|
|
|
ksp(libs.destinations.ksp)
|
|
|
|
|
2024-04-25 18:10:19 +08:00
|
|
|
implementation(libs.reorderable)
|
2023-08-31 22:22:03 +08:00
|
|
|
|
|
|
|
implementation(libs.androidx.splashscreen)
|
2023-11-08 21:46:31 +08:00
|
|
|
|
|
|
|
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)
|
2024-04-29 22:05:53 +08:00
|
|
|
implementation(libs.permissions)
|
2024-08-14 19:46:44 +08:00
|
|
|
|
|
|
|
implementation(libs.json5)
|
2021-11-19 14:08:52 +08:00
|
|
|
}
|