NuvioStreaming/androidApp/build.gradle.kts
2026-06-19 16:18:32 +05:30

118 lines
4.1 KiB
Text

import java.util.Properties
fun readXcconfigValue(file: File, key: String): String? {
if (!file.exists()) return null
return file.readLines()
.asSequence()
.map(String::trim)
.filter { it.isNotEmpty() && !it.startsWith("#") && it.contains('=') }
.map { line ->
val separatorIndex = line.indexOf('=')
line.substring(0, separatorIndex).trim() to line.substring(separatorIndex + 1).trim()
}
.firstOrNull { (entryKey, _) -> entryKey == key }
?.second
}
plugins {
alias(libs.plugins.androidApplication)
}
val localProps = Properties().apply {
val propsFile = rootProject.file("local.properties")
if (propsFile.exists()) propsFile.inputStream().use { load(it) }
}
val releaseStoreFile = localProps.getProperty("NUVIO_RELEASE_STORE_FILE")?.takeIf { it.isNotBlank() }
val releaseStorePassword = localProps.getProperty("NUVIO_RELEASE_STORE_PASSWORD")?.takeIf { it.isNotBlank() }
val releaseKeyAlias = localProps.getProperty("NUVIO_RELEASE_KEY_ALIAS")?.takeIf { it.isNotBlank() }
val releaseKeyPassword = localProps.getProperty("NUVIO_RELEASE_KEY_PASSWORD")?.takeIf { it.isNotBlank() }
val releaseKeystore = releaseStoreFile?.let(rootProject::file)
val appVersionConfigFile = rootProject.file("iosApp/Configuration/Version.xcconfig")
val releaseAppVersionName = readXcconfigValue(appVersionConfigFile, "MARKETING_VERSION")
?: error("MARKETING_VERSION is missing from ${appVersionConfigFile.path}")
val releaseAppVersionCode = readXcconfigValue(appVersionConfigFile, "CURRENT_PROJECT_VERSION")
?.toIntOrNull()
?: error("CURRENT_PROJECT_VERSION is missing or invalid in ${appVersionConfigFile.path}")
android {
namespace = "com.nuvio.android"
compileSdk = libs.versions.android.compileSdk.get().toInt()
compileSdkMinor = libs.versions.android.compileSdkMinor.get().toInt()
signingConfigs {
create("release") {
if (releaseKeystore != null && releaseStorePassword != null && releaseKeyAlias != null && releaseKeyPassword != null) {
storeFile = releaseKeystore
storePassword = releaseStorePassword
keyAlias = releaseKeyAlias
keyPassword = releaseKeyPassword
}
}
}
defaultConfig {
applicationId = "com.nuvio.app"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = releaseAppVersionCode
versionName = releaseAppVersionName
}
flavorDimensions += "distribution"
productFlavors {
create("full") {
dimension = "distribution"
}
create("playstore") {
dimension = "distribution"
}
}
sourceSets.getByName("full") {
manifest.srcFile("src/full/AndroidManifest.xml")
jniLibs.directories.add("../composeApp/src/full/jniLibs")
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
jniLibs {
useLegacyPackaging = true
pickFirsts += listOf(
"lib/*/libc++_shared.so",
"lib/*/libavcodec.so",
"lib/*/libavutil.so",
"lib/*/libswscale.so",
"lib/*/libswresample.so"
)
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"../composeApp/proguard-rules.pro",
)
signingConfig = signingConfigs.getByName("release")
ndk {
debugSymbolLevel = "FULL"
}
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
dependencies {
implementation(project(":composeApp"))
coreLibraryDesugaring(libs.desugar.jdk.libs)
debugImplementation(libs.compose.uiTooling)
}