130 lines
4.3 KiB
Kotlin
130 lines
4.3 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")
|
||
kotlin("kapt")
|
||
}
|
||
|
||
|
||
|
||
|
||
// === 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 = 35
|
||
|
||
defaultConfig {
|
||
applicationId = "app.klottr"
|
||
minSdk = 26
|
||
targetSdk = 35
|
||
versionCode = 11
|
||
versionName = "0.2.4.1"
|
||
|
||
// 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")
|
||
|
||
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(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")
|
||
// --- Nätverk ---
|
||
implementation("com.squareup.retrofit2:retrofit:2.11.0")
|
||
implementation("com.squareup.retrofit2:converter-moshi:2.11.0")
|
||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
|
||
implementation("com.squareup.moshi:moshi-kotlin:1.15.1")
|
||
// 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")
|
||
|
||
// 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.6.1"
|
||
implementation("androidx.room:room-runtime:$room")
|
||
kapt("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")
|
||
}
|
||
|
||
androidComponents {
|
||
onVariants { v ->
|
||
println("### Klottr: variant=${v.name}, applicationId=${v.applicationId.get()}")
|
||
}
|
||
} |