forked from gkd-kit/gkd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
229 lines (193 loc) · 7.19 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import com.android.build.gradle.internal.cxx.json.jsonStringOf
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
errorOutput = ByteArrayOutputStream()
}
return String(byteOut.toByteArray()).trim()
}
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
},
)
} catch (e: Exception) {
println("app: git is not available")
null
}
val vnSuffix = "-${gitInfo?.commitId?.substring(0, 7) ?: "unknown"}"
plugins {
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)
}
android {
namespace = "li.songe.gkd"
compileSdk = libs.versions.compileSdk.get().toInt()
buildToolsVersion = libs.versions.buildToolsVersion.get()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
applicationId = "li.songe.gkd"
versionCode = 28
versionName = "1.7.3"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
val nowTime = System.currentTimeMillis()
buildConfigField("Long", "BUILD_TIME", jsonStringOf(nowTime) + "L")
buildConfigField(
"String",
"GIT_COMMIT_ID",
jsonStringOf(gitInfo?.commitId)
)
resourceConfigurations.addAll(listOf("zh", "en"))
ndk {
// noinspection ChromeOsAbiSupport
abiFilters += listOf("arm64-v8a", "x86_64")
}
}
lint {
disable.add("ModifierFactoryUnreferencedReceiver")
}
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
}
} else {
signingConfigs.getByName("debug")
}
buildTypes {
all {
signingConfig = currentSigning
}
release {
if (gitInfo?.tagName == null) {
versionNameSuffix = vnSuffix
}
isMinifyEnabled = true
isShrinkResources = true
setProguardFiles(
listOf(
// /sdk/tools/proguard/proguard-android-optimize.txt
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
)
}
debug {
versionNameSuffix = vnSuffix
applicationIdSuffix = ".debug"
resValue("string", "app_name", "GKD-debug")
resValue("string", "capture_label", "捕获快照-debug")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.majorVersion
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
freeCompilerArgs += "-opt-in=kotlinx.coroutines.FlowPreview"
freeCompilerArgs += "-opt-in=androidx.compose.material3.ExperimentalMaterial3Api"
freeCompilerArgs += "-opt-in=androidx.compose.foundation.ExperimentalFoundationApi"
}
buildFeatures {
buildConfig = true
compose = true
aidl = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
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")
}
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("room.incremental", "true")
arg("room.generateKotlin", "true")
}
sourceSets.configureEach {
kotlin.srcDir("${layout.buildDirectory.asFile.get()}/generated/ksp/$name/kotlin/")
}
}
dependencies {
implementation(project(mapOf("path" to ":selector")))
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.compose.ui)
implementation(libs.compose.material3)
implementation(libs.compose.icons)
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)
compileOnly(project(mapOf("path" to ":hidden_api")))
implementation(libs.rikka.shizuku.api)
implementation(libs.rikka.shizuku.provider)
implementation(libs.lsposed.hiddenapibypass)
implementation(libs.tencent.mmkv)
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.room.paging)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.paging.runtime)
implementation(libs.androidx.paging.compose)
implementation(libs.ktor.server.core)
implementation(libs.ktor.server.cio)
implementation(libs.ktor.server.content.negotiation)
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.okhttp)
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)
implementation(libs.destinations.core)
ksp(libs.destinations.ksp)
implementation(libs.google.hilt.android)
ksp(libs.google.hilt.android.compiler)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.others.reorderable)
implementation(libs.androidx.splashscreen)
implementation(libs.coil.compose)
implementation(libs.coil.gif)
implementation(libs.exp4j)
implementation(libs.toaster)
}