apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'de.mannodermaus.android-junit5'

android {
    compileSdkVersion compile_sdk

    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'LICENSE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

    defaultConfig {
        applicationId "es.ffgiraldez.comicsearch"
        minSdkVersion min_sdk
        versionCode 1
        versionName "1.0"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments += [
                        "room.schemaLocation"  : "$projectDir/schemas".toString(),
                        "room.incremental"     : "true",
                        "room.expandProjection": "true"
                ]
            }
        }

    }

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

    buildFeatures {
        dataBinding true
    }

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

    androidExtensions {
        experimental = true
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
    kotlinOptions {
        useIR = false // https://github.com/cashapp/turbine/issues/10
        languageVersion = '1.4'
        jvmTarget = JavaVersion.VERSION_1_8
        freeCompilerArgs += [
                '-Xopt-in=kotlinx.coroutines.FlowPreview',
                '-Xopt-in=kotlin.experimental.ExperimentalTypeInference',
                '-Xopt-in=kotlin.time.ExperimentalTime',
                '-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi',
        ]
    }
}

dependencies {
    kapt libs.androidx_room_compiler
    kaptTest libs.androidx_room_compiler

    implementation libs.androidx_constraint
    implementation libs.androidx_livedata
    implementation libs.androidx_room
    implementation libs.androidx_viewmodel
    implementation libs.arrow
    implementation libs.arrow_fx
    implementation libs.arrow_fx_coroutines
    implementation(libs.floating_search) {
        exclude module: 'support-v4'
    }
    implementation libs.material
    implementation libs.okhttp
    implementation libs.okhttp_logging
    implementation libs.picasso
    implementation libs.koin
    implementation libs.koin_android
    implementation libs.koin_architecture
    implementation libs.kotlin_stdlib
    implementation libs.kotlinx_coroutines
    implementation libs.retrofit
    implementation libs.retrofit_gson
    implementation libs.steho

    testImplementation(libs.androidx_room_test) {
        exclude module: 'junit'
    }
    testImplementation(libs.androidx_test) {
        exclude module: 'junit'
    }
    testImplementation libs.kotlinx_coroutines_test
    testImplementation libs.junit_api
    testImplementation libs.junit_params
    testImplementation libs.mockito_core
    testImplementation libs.mockito_kotlin
    testImplementation libs.kotest_runner
    testImplementation libs.kotest_assertions
    testImplementation libs.kotest_property
    testImplementation(libs.koin_test) {
        exclude module: 'junit'
    }
    testImplementation libs.turbine
    testRuntimeOnly libs.junit_engine
}
repositories {
    mavenCentral()
}