Files
netdesk/native/ui/android/app/build.gradle.kts
T

84 lines
2.9 KiB
Kotlin

import java.util.Properties
import java.io.FileInputStream
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")
}
// ---------------------------------------------------------------------------
// NetDesk release signing.
// Credentials live in android/key.properties (git-ignored). Generate the
// keystore + this file with: packaging\build-android.ps1 -GenerateKeystore
// When key.properties is absent the release build falls back to DEBUG signing
// so `flutter run --release` keeps working for local development.
// ---------------------------------------------------------------------------
val keystorePropertiesFile = rootProject.file("key.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
FileInputStream(keystorePropertiesFile).use { keystoreProperties.load(it) }
}
android {
namespace = "space.netdesk"
compileSdk = flutter.compileSdkVersion
// NetDesk ships prebuilt Rust .so under src/main/jniLibs/<abi>/libnetdesk_core.so
// (produced by cargo-ndk). Point AGP at the NDK already on disk via
// ANDROID_NDK_HOME so a Gradle build never triggers an NDK download; fall
// back to Flutter's pinned NDK version when the env var is not set.
val ndkHomeEnv = System.getenv("ANDROID_NDK_HOME")
if (ndkHomeEnv != null && file(ndkHomeEnv).exists()) {
ndkPath = ndkHomeEnv
} else {
ndkVersion = flutter.ndkVersion
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
defaultConfig {
// NetDesk application id (reverse of netdesk.space).
applicationId = "space.netdesk"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
signingConfigs {
create("release") {
if (keystorePropertiesFile.exists()) {
keyAlias = keystoreProperties["keyAlias"] as String?
keyPassword = keystoreProperties["keyPassword"] as String?
storeFile = (keystoreProperties["storeFile"] as String?)?.let { file(it) }
storePassword = keystoreProperties["storePassword"] as String?
}
}
}
buildTypes {
release {
// Use the real upload key when key.properties is present, else debug.
signingConfig = if (keystorePropertiesFile.exists()) {
signingConfigs.getByName("release")
} else {
signingConfigs.getByName("debug")
}
}
}
}
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}
flutter {
source = "../.."
}