Wraps Google Maps on both Android and iOS Also bumps targetSDK to 36 because it was required by the library.
139 lines
4.6 KiB
Kotlin
139 lines
4.6 KiB
Kotlin
import java.time.Instant
|
||
import java.util.Properties
|
||
// import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
|
||
|
||
|
||
plugins {
|
||
id("org.jetbrains.kotlin.plugin.compose")
|
||
id("com.android.application")
|
||
kotlin("android")
|
||
alias(libs.plugins.ksp)
|
||
}
|
||
|
||
// === Läs local.properties utan java.util.Properties ===
|
||
val localProps: Map<String, String> = run {
|
||
val file = rootProject.file("local.properties")
|
||
if (!file.exists()) emptyMap()
|
||
else file.readLines()
|
||
.asSequence()
|
||
.map { it.trim() }
|
||
.filter { it.isNotEmpty() && !it.startsWith("#") && it.contains("=") }
|
||
.map {
|
||
val i = it.indexOf('=')
|
||
val k = it.substring(0, i).trim()
|
||
val v = it.substring(i + 1).trim()
|
||
k to v
|
||
}
|
||
.toMap()
|
||
}
|
||
|
||
val klLogDebug = localProps["KLLOG_DEBUG"]?.toBoolean() ?: false
|
||
val klLogHttpDebug = localProps["KLLOG_HTTP_DEBUG"]?.toBoolean() ?: false
|
||
|
||
|
||
fun propOrEmpty(key: String) = localProps[key] ?: ""
|
||
// ======================================================
|
||
|
||
|
||
android {
|
||
namespace = "app.klottr"
|
||
compileSdk = 36
|
||
|
||
defaultConfig {
|
||
applicationId = "app.klottr"
|
||
minSdk = 26
|
||
targetSdk = 36
|
||
versionCode = 14
|
||
versionName = "0.3.0"
|
||
|
||
// Byggtid i UTC (ISO 8601) genereras vid build-konfiguration
|
||
val buildTimeUtc = Instant.now().toString()
|
||
buildConfigField("String", "BUILD_TIME_UTC", "\"$buildTimeUtc\"")
|
||
buildConfigField("String", "APP_NAME", "\"Klottr\"")
|
||
|
||
|
||
// BuildConfig-fält (åtkomst i Kotlin via BuildConfig.X)
|
||
buildConfigField("String", "SERVER_API_BASE_URL", "\"${propOrEmpty("SERVER_API_BASE_URL")}\"")
|
||
buildConfigField("String", "SERVER_API_KEY", "\"${propOrEmpty("SERVER_API_KEY")}\"")
|
||
buildConfigField("String", "WEB_CLIENT_ID", "\"${propOrEmpty("WEB_CLIENT_ID")}\"")
|
||
|
||
// Skicka Maps‑nyckeln som manifest‑placeholder (används i AndroidManifest.xml)
|
||
manifestPlaceholders["MAPS_API_KEY"] = propOrEmpty("MAPS_API_KEY")
|
||
|
||
// Digitalt Museum
|
||
buildConfigField("String", "DM_API_KEY", "\"${propOrEmpty("DM_API_KEY")}\"")
|
||
buildConfigField("String", "DM_OWNERS", "\"${propOrEmpty("DM_OWNERS")}\"")
|
||
|
||
|
||
|
||
buildConfigField("boolean", "KLLOG_DEBUG", klLogDebug.toString())
|
||
buildConfigField("boolean", "KLLOG_HTTP_DEBUG", klLogHttpDebug.toString())
|
||
}
|
||
|
||
buildFeatures {
|
||
compose = true
|
||
buildConfig = true
|
||
}
|
||
kotlinOptions { jvmTarget = "17" }
|
||
|
||
compileOptions {
|
||
sourceCompatibility = JavaVersion.VERSION_17
|
||
targetCompatibility = JavaVersion.VERSION_17
|
||
}
|
||
}
|
||
|
||
dependencies {
|
||
// Compose
|
||
val composeBom = platform("androidx.compose:compose-bom:2025.01.00")
|
||
implementation(project(":shared"))
|
||
implementation(composeBom)
|
||
androidTestImplementation(composeBom)
|
||
implementation("androidx.activity:activity-compose:1.9.3")
|
||
implementation("androidx.compose.ui:ui")
|
||
implementation("androidx.compose.material3:material3:1.3.0")
|
||
implementation("androidx.compose.ui:ui-tooling-preview")
|
||
debugImplementation("androidx.compose.ui:ui-tooling")
|
||
implementation("com.google.android.material:material:1.12.0")
|
||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.9.0")
|
||
|
||
// Google Maps (Compose + Play Services)
|
||
implementation("com.google.maps.android:maps-compose:4.4.1")
|
||
// implementation("com.google.android.gms:play-services-maps:18.2.0") // This is now included in :shared
|
||
|
||
// Google Sign-In
|
||
implementation("com.google.android.gms:play-services-auth:21.2.0")
|
||
|
||
// Lifecycle
|
||
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6")
|
||
|
||
// Room
|
||
val room = "2.7.2"
|
||
implementation("androidx.room:room-runtime:$room")
|
||
ksp("androidx.room:room-compiler:$room")
|
||
implementation("androidx.room:room-ktx:$room")
|
||
|
||
// Play Services Location
|
||
implementation("com.google.android.gms:play-services-location:21.3.0")
|
||
|
||
// Coroutines
|
||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")
|
||
|
||
// WorkManager (valfritt, ej nödvändigt här)
|
||
implementation("androidx.work:work-runtime-ktx:2.9.1")
|
||
|
||
|
||
// Dessa kommer så småningom bara behövas i shared, men lägger dem här för att förenkla portning
|
||
// Coil 3 (KMP) — image loading + caching for Compose Multiplatform
|
||
implementation("io.coil-kt.coil3:coil-compose:3.3.0")
|
||
// Use Ktor-based multiplatform networking backend for Coil
|
||
implementation("io.coil-kt.coil3:coil-network-ktor3:3.3.0")
|
||
|
||
|
||
|
||
}
|
||
|
||
androidComponents {
|
||
onVariants { v ->
|
||
println("### Klottr: variant=${v.name}, applicationId=${v.applicationId.get()}")
|
||
}
|
||
} |