106 lines
3.9 KiB
Plaintext
106 lines
3.9 KiB
Plaintext
import java.util.Properties
|
||
|
||
plugins {
|
||
id("com.android.application")
|
||
id("org.jetbrains.kotlin.android")
|
||
id("rust")
|
||
}
|
||
|
||
val tauriProperties = Properties().apply {
|
||
val propFile = file("tauri.properties")
|
||
if (propFile.exists()) {
|
||
propFile.inputStream().use { load(it) }
|
||
}
|
||
}
|
||
|
||
// 加载签名密钥配置
|
||
// keystore.properties文件应包含:storeFile, storePassword, keyPassword, keyAlias
|
||
// 如果文件不存在,将使用debug签名(适用于CI/CD环境)
|
||
val keystoreProperties = Properties().apply {
|
||
val propFile = file("../../../../keystore.properties")
|
||
if (propFile.exists()) {
|
||
propFile.inputStream().use { load(it) }
|
||
}
|
||
}
|
||
|
||
android {
|
||
compileSdk = 34
|
||
namespace = "com.countdown.app"
|
||
defaultConfig {
|
||
manifestPlaceholders["usesCleartextTraffic"] = "false"
|
||
applicationId = "com.countdown.app"
|
||
minSdk = 24
|
||
targetSdk = 34
|
||
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
||
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
||
}
|
||
|
||
// 签名配置
|
||
signingConfigs {
|
||
create("release") {
|
||
// 检查是否存在密钥配置,如果没有则使用debug签名
|
||
// 这确保了CI/CD环境可以正常构建,即使没有生产密钥
|
||
if (keystoreProperties.containsKey("keyAlias")) {
|
||
keyAlias = keystoreProperties["keyAlias"] as String
|
||
keyPassword = keystoreProperties["keyPassword"] as String
|
||
storeFile = file("../../../../${keystoreProperties["storeFile"]}")
|
||
storePassword = keystoreProperties["storePassword"] as String
|
||
println("✓ 使用自定义签名密钥: ${keystoreProperties["keyAlias"]}")
|
||
} else {
|
||
// 如果没有密钥配置,使用debug签名配置
|
||
// CI/CD环境通常不需要生产签名
|
||
println("⚠ 未找到keystore.properties,将使用debug签名")
|
||
}
|
||
}
|
||
}
|
||
buildTypes {
|
||
getByName("debug") {
|
||
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
||
isDebuggable = true
|
||
isJniDebuggable = true
|
||
isMinifyEnabled = false
|
||
packaging { jniLibs.keepDebugSymbols.add("*/arm64-v8a/*.so")
|
||
jniLibs.keepDebugSymbols.add("*/armeabi-v7a/*.so")
|
||
jniLibs.keepDebugSymbols.add("*/x86/*.so")
|
||
jniLibs.keepDebugSymbols.add("*/x86_64/*.so")
|
||
}
|
||
}
|
||
getByName("release") {
|
||
isMinifyEnabled = true
|
||
proguardFiles(
|
||
*fileTree(".") { include("**/*.pro") }
|
||
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
|
||
.toList().toTypedArray()
|
||
)
|
||
// 应用签名配置:有自定义密钥时使用自定义签名,否则使用debug签名
|
||
// 这确保CI/CD环境能正常构建release版本,即使没有生产密钥
|
||
if (keystoreProperties.containsKey("keyAlias")) {
|
||
signingConfig = signingConfigs.getByName("release")
|
||
} else {
|
||
// 在CI/CD环境中,如果没有生产密钥,使用debug签名
|
||
signingConfig = signingConfigs.getByName("debug")
|
||
}
|
||
}
|
||
}
|
||
kotlinOptions {
|
||
jvmTarget = "1.8"
|
||
}
|
||
buildFeatures {
|
||
buildConfig = true
|
||
}
|
||
}
|
||
|
||
rust {
|
||
rootDirRel = "../../../"
|
||
}
|
||
|
||
dependencies {
|
||
implementation("androidx.webkit:webkit:1.6.1")
|
||
implementation("androidx.appcompat:appcompat:1.6.1")
|
||
implementation("com.google.android.material:material:1.8.0")
|
||
testImplementation("junit:junit:4.13.2")
|
||
androidTestImplementation("androidx.test.ext:junit:1.1.4")
|
||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||
}
|
||
|
||
apply(from = "tauri.build.gradle.kts") |