plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'kotlin-parcelize'
    id 'kotlin-kapt'
    id 'org.jetbrains.kotlin.plugin.serialization'
}

android {
    compileSdkVersion versions.compileSdk
    buildToolsVersion versions.buildTools

    defaultConfig {
        minSdkVersion versions.minSdk
        targetSdkVersion versions.targetSdk

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"

        javaCompileOptions {
            annotationProcessorOptions {
                arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        all {
            Properties properties = new Properties()
            properties.load(project.rootProject.file("local.properties").newDataInputStream())
            def KEY_4A = properties.getProperty("KEY_4A", "")
            def KEY_4B = properties.getProperty("KEY_4B", "")
            def KEY_5A = properties.getProperty("KEY_5A", "")
            def KEY_5B = properties.getProperty("KEY_5B", "")
            it.buildConfigField "String", "KEY_4A", "\"$KEY_4A\""
            it.buildConfigField "String", "KEY_4B", "\"$KEY_4B\""
            it.buildConfigField "String", "KEY_5A", "\"$KEY_5A\""
            it.buildConfigField "String", "KEY_5B", "\"$KEY_5B\""
        }
    }
    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
        freeCompilerArgs += [
                "-Xinline-classes",
                "-Xallow-result-return-type",
                "-Xuse-experimental=" +
                        "kotlin.Experimental," +
                        "kotlinx.coroutines.ExperimentalCoroutinesApi," +
                        "kotlinx.coroutines.InternalCoroutinesApi," +
                        "kotlinx.coroutines.FlowPreview"
        ]
    }
}

dependencies {
    coreLibraryDesugaring libs.desugaring
    api libs.appcompat
    api libs.coroutines
    api libs.kotlinStdLib
    api libs.livedataKtx
    api libs.logger
    api libs.kotpref
    api libs.kotprefEnum
    api libs.serialization
    api libs.roomKtx
    api libs.roomRuntime
    kapt libs.roomCompiler
}