80 lines
2.9 KiB
Kotlin
80 lines
2.9 KiB
Kotlin
plugins {
|
|
id("com.android.application")
|
|
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
|
id("dev.flutter.flutter-gradle-plugin")
|
|
}
|
|
|
|
// 在任务创建前校验,避免缺配置时 AGP 仅报签名任务不存在。
|
|
if (gradle.startParameter.taskNames.any { it.contains("release", ignoreCase = true) }) {
|
|
for (name in listOf("DSH_KEYSTORE", "DSH_STORE_PASSWORD", "DSH_KEY_ALIAS", "DSH_KEY_PASSWORD")) {
|
|
check(!System.getenv(name).isNullOrBlank()) { "Release signing requires $name" }
|
|
}
|
|
}
|
|
|
|
android {
|
|
namespace = "ren.misaka.dshapp"
|
|
compileSdk { version = release(37) { minorApiLevel = 0 } }
|
|
ndkVersion = flutter.ndkVersion
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
defaultConfig {
|
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
|
applicationId = "ren.misaka.dshapp"
|
|
// You can update the following values to match your application needs.
|
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
|
minSdk = 26
|
|
targetSdk = flutter.targetSdkVersion
|
|
// Uses the version code from pubspec.yaml. When using split APKs, 1000 * ABI_VERSION
|
|
// is added automatically by Flutter. (https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions)
|
|
// You can force using the value of versionCode by specifying the `-P force-version-code-ignoring-abi=true`
|
|
// flag during build.
|
|
versionCode = flutter.versionCode
|
|
versionName = flutter.versionName
|
|
}
|
|
|
|
signingConfigs {
|
|
create("release") {
|
|
storeFile = System.getenv("DSH_KEYSTORE")?.let { file(it) }
|
|
storePassword = System.getenv("DSH_STORE_PASSWORD")
|
|
keyAlias = System.getenv("DSH_KEY_ALIAS")
|
|
keyPassword = System.getenv("DSH_KEY_PASSWORD")
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
signingConfig = signingConfigs.getByName("release")
|
|
}
|
|
}
|
|
}
|
|
|
|
// 直接运行 Gradle/Flutter 也不能绕过 release 签名要求。debug 开发不受影响。
|
|
gradle.taskGraph.whenReady {
|
|
if (allTasks.any { it.project == project && it.name.contains("Release") }) {
|
|
for (name in listOf("DSH_KEYSTORE", "DSH_STORE_PASSWORD", "DSH_KEY_ALIAS", "DSH_KEY_PASSWORD")) {
|
|
check(!System.getenv(name).isNullOrBlank()) {
|
|
"Release signing requires $name; use build.sh --keystore PATH --alias NAME"
|
|
}
|
|
}
|
|
check(file(System.getenv("DSH_KEYSTORE")).isFile) { "Signing keystore does not exist" }
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
compilerOptions {
|
|
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
|
|
}
|
|
}
|
|
|
|
flutter {
|
|
source = "../.."
|
|
}
|
|
|
|
dependencies {
|
|
implementation("org.mozilla.geckoview:geckoview:158.0.20261007201254")
|
|
}
|