plugins {
    id 'com.google.devtools.ksp'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'dagger.hilt.android.plugin'

ext {
    coroutines_version = "1.10.2"
    room_version = "2.7.1"
}

repositories {
    google()
}

android {
    compileSdk 34
    namespace "com.farmerbb.appnotifier"

    defaultConfig {
        applicationId "com.farmerbb.appnotifier"

        minSdkVersion 21
        targetSdkVersion 34
        versionCode 11
        versionName "1.2.5"

        resConfigs "en", "fr", "de", "sv", "pl", "ko", "it", "tr", "ja"
        vectorDrawables.generatedDensities = []

        buildConfigField "long", "TIMESTAMP", "${System.currentTimeMillis()}L"

        javaCompileOptions {
            annotationProcessorOptions {
                arguments += ["room.incremental": "true"]
            }
        }
    }

    buildFeatures {
        buildConfig true
    }

    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_21
        targetCompatibility JavaVersion.VERSION_21
    }

    kotlinOptions {
        jvmTarget = '21'
    }

    signingConfigs {
        release {
            if(System.getenv("KSTOREFILE") != null)
                storeFile file(System.getenv("KSTOREFILE"))

            storePassword System.getenv("KSTOREPWD")
            keyAlias System.getenv("KEYALIAS")
            keyPassword System.getenv("KEYPWD")
        }
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            manifestPlaceholders = [appName: "@string/app_name_debug"]
        }

        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
            manifestPlaceholders = [appName: "@string/app_name"]

            applicationVariants.all { variant ->
                variant.outputs.all {
                    outputFileName = "${project.parent.name}-${defaultConfig.versionName}.apk"
                }
            }
        }
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"

    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'androidx.preference:preference-ktx:1.2.1'
    implementation "androidx.room:room-runtime:$room_version"
    implementation "androidx.room:room-rxjava2:$room_version"
    implementation "androidx.room:room-ktx:$room_version"
    ksp "androidx.room:room-compiler:$room_version"

    implementation "com.google.dagger:hilt-android:$hilt_version"
    ksp "com.google.dagger:hilt-compiler:$hilt_version"

    coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.5"
}
