import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.compose)
}

android {
    namespace = "club.clubk.ktag.apps"
    compileSdk = 36

    defaultConfig {
        applicationId = "club.clubk.ktag.apps"
        minSdk = 24
        targetSdk = 34
        versionCode = 1
        versionName = "1.0"

        val gitHashProvider = providers.exec {
            commandLine("git", "rev-parse", "--short", "HEAD")
        }.standardOutput.asText

        val gitHash = gitHashProvider.get().trim()
        val buildTime = SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US).format(Date())

        buildConfigField("String", "GIT_HASH", "\"$gitHash\"")
        buildConfigField("String", "BUILD_TIME", "\"$buildTime\"")
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    buildFeatures {
        buildConfig = true
        compose = true
    }

    packaging {
        resources {
            excludes += listOf(
                "META-INF/INDEX.LIST",
                "META-INF/io.netty.versions.properties",
                "META-INF/DEPENDENCIES"
            )
        }
    }
}

dependencies {
    implementation(project(":core"))
    implementation(project(":subapp-sample"))
    implementation(project(":subapp-bletool"))
    implementation(project(":subapp-koth"))
    implementation(project(":subapp-medic"))
    implementation(project(":subapp-terminal"))
    implementation(project(":subapp-mine"))
    implementation(project(":subapp-konfigurator"))
    implementation(project(":subapp-sentry"))
    implementation(project(":mqtt-broker"))
    implementation(project(":shared-services"))

    implementation("androidx.appcompat:appcompat:1.7.0")
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.activity.compose)
    implementation(platform(libs.androidx.compose.bom))
    implementation(libs.androidx.compose.ui)
    implementation(libs.androidx.compose.ui.graphics)
    implementation(libs.androidx.compose.material3)
    implementation(libs.androidx.compose.ui.tooling.preview)
    debugImplementation(libs.androidx.compose.ui.tooling)
}
