plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-parcelize'
    id 'kotlin-kapt'
}

static def getDate() {
    new Date().format('yyyyMMddHHmm')
}

android {
    namespace 'sk.minv.sample_app'

    compileSdk Integer.parseInt(COMPILE_SDK_VERSION)

    defaultConfig {
        applicationId "sk.minv.sample_app"
        minSdkVersion Integer.parseInt(MIN_SDK_VERSION)
        targetSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)
        versionCode Integer.parseInt(VERSION_CODE)
        versionName VERSION_NAME
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        viewBinding true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
    }

    android.applicationVariants.configureEach { variant ->
        variant.outputs.configureEach {
            if (variant.buildType.name == "release") {
                outputFileName = "sample_app-release-${defaultConfig.versionName}-${defaultConfig.versionCode}-${getDate()}.apk"
            } else if (variant.buildType.name == "debug") {
                outputFileName = "sample_app-debug-${defaultConfig.versionName}-${defaultConfig.versionCode}-${getDate()}.apk"
            }
        }
    }
}

dependencies {
    // Modules
    implementation project(':base')

    // EID SDK
    implementation "sk.eid:eid-sdk:1.4.2"
    implementation "sk.eid:eid-exceptions-sdk:1.4.2"

    // AndroidX
    implementation "androidx.core:core-ktx:$androidx_version"

    // Kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    // Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_core_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_android_version"

    // Architecture components
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$architecture_components_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$architecture_components_version"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$architecture_components_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$architecture_components_version"
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_extensions_version"

    // UI
    implementation "androidx.appcompat:appcompat:$appcompat_version"
    implementation "androidx.recyclerview:recyclerview:$recycler_view"
    implementation "androidx.constraintlayout:constraintlayout:$constrain_layout_version"
    implementation "com.google.android.material:material:$material_design_components_version"

    // Dependency injection
    implementation "io.insert-koin:koin-android:$koin_version"

    // Retrofit
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation "com.squareup.okhttp3:logging-interceptor:$okHttp_version"

    // Shared preferences
    implementation "androidx.preference:preference-ktx:$default_shared_preferences_version"
    implementation "androidx.security:security-crypto:$crypto_shared_preferences_version"

    // Logger
    implementation "com.jakewharton.timber:timber:$timber_version"

    // JSON serialization/deserialization
    implementation 'com.google.code.gson:gson:2.9.0'

    // Google vision
    implementation 'com.google.android.gms:play-services-vision:20.1.3'

    // Test
    testImplementation "junit:junit:$junit_version"
    androidTestImplementation "androidx.test.ext:junit:$test_junit_version"
    androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
}