import java.util.Properties

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.compose.compiler)
    alias(libs.plugins.dagger.hilt)
    alias(libs.plugins.ksp)
}

val localProps = Properties().apply {
    val file = rootProject.file("local.properties")
    if (file.exists()) {
        file.inputStream().use { load(it) }
    }
}

android {
    namespace = "com.github.nullptroma.wallenc.app"
    compileSdk = 37

    defaultConfig {
        applicationId = "com.github.nullptroma.wallenc.app"
        minSdk = 26
        targetSdk = 37
        versionCode = 1
        versionName = "1.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments["yandex.oauth.token"] =
            localProps.getProperty("yandex.test.oauth.token").orEmpty()
        vectorDrawables {
            useSupportLibrary = true
        }

        manifestPlaceholders["YANDEX_CLIENT_ID"] = "0854a43a284a445480c5ced2258f2069"
    }

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

    buildFeatures {
        compose = true
    }

    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
}

kotlin {
    jvmToolchain(17)
}

dependencies {
    // Timber
    implementation(libs.timber)

    // Yandex
    implementation(libs.yandex.oauth)

    // Hilt
    implementation(libs.dagger.hilt)
    ksp(libs.dagger.hilt.compiler)
    implementation(libs.androidx.hilt.work)
    ksp(libs.androidx.hilt.compiler)

    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.appcompat)
    implementation(libs.androidx.datastore.preferences)
    implementation(libs.androidx.work.runtime.ktx)
    implementation(libs.androidx.lifecycle.runtime.ktx)
    implementation(libs.androidx.activity.compose)
    implementation(platform(libs.androidx.compose.bom))
    implementation(libs.androidx.ui)

    testImplementation(libs.junit)
    androidTestImplementation(libs.androidx.junit)
    androidTestImplementation(libs.androidx.espresso.core)
    androidTestImplementation(libs.kotlinx.coroutines.test)
    androidTestImplementation(libs.room.testing)
    androidTestImplementation(platform(libs.androidx.compose.bom))
    androidTestImplementation(libs.okhttp3)
    androidTestImplementation(libs.retrofit)
    androidTestImplementation(libs.retrofit.converter.jackson)
    androidTestImplementation(libs.jackson.module.kotlin)
    androidTestImplementation(libs.jackson.datatype.jsr310)

    implementation(project(":domain"))
    implementation(project(":usecases"))
    implementation(project(":domain-vault"))
    implementation(project(":infrastructure-android"))
    implementation(project(":task-runtime"))
    implementation(project(":ui"))
    implementation(project(":vault-contracts"))
}