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

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.florianwalther.incentivetimer"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.1.0-rc02'
        kotlinCompilerVersion '1.6.10'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        freeCompilerArgs += ["-Xuse-experimental=androidx.compose.material.ExperimentalMaterialApi"]
        freeCompilerArgs += ["-Xuse-experimental=androidx.compose.animation.ExperimentalAnimationApi"]
        freeCompilerArgs += ["-Xuse-experimental=androidx.compose.ui.ExperimentalComposeUiApi"]
        freeCompilerArgs += ["-Xuse-experimental=androidx.compose.foundation.ExperimentalFoundationApi"]
        freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
    implementation 'androidx.activity:activity-compose:1.4.0'
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"

    // Compose UI Util
    implementation "androidx.compose.ui:ui-util:$compose_version"

    // Compose Navigation
    implementation "androidx.navigation:navigation-compose:2.4.0-rc01"

    // Compose Extended Icons
    implementation "androidx.compose.material:material-icons-extended:$compose_version"

    // ViewModel + LiveData
    def lifecycle_version = "2.4.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
    kapt "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

    // DataStore
    implementation "androidx.datastore:datastore-preferences:1.0.0"

    // Room
    def room_version = "2.4.1"
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
    implementation "androidx.room:room-ktx:$room_version"

    // Hilt
    implementation "com.google.dagger:hilt-android:2.38.1"
    kapt "com.google.dagger:hilt-compiler:2.38.1"
    implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'

    // Accompanist libraries
    implementation "com.google.accompanist:accompanist-flowlayout:0.21.4-beta"
    implementation "com.google.accompanist:accompanist-systemuicontroller:0.24.1-alpha"

    // Logcat
    implementation 'com.squareup.logcat:logcat:0.1'

    // Zhuinden flow-combinetuple
    implementation 'com.github.Zhuinden:flow-combinetuple-kt:1.1.1'

    // MPAndroidChart
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'

    // Testing dependencies

    // Default dependencies
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"

    // Coroutines
    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0'

    // Architecture Components
    testImplementation 'androidx.arch.core:core-testing:2.1.0'

    // Truth
    testImplementation "com.google.truth:truth:1.1.3"
    testImplementation "com.google.truth.extensions:truth-java8-extension:1.1.3"

    // Turbine
    testImplementation 'app.cash.turbine:turbine:0.7.0'

    // MockK
    testImplementation "io.mockk:mockk:1.12.2"
}

kapt {
    correctErrorTypes true
}