plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id "androidx.navigation.safeargs.kotlin"
    id 'kotlin-kapt'
    id 'kotlin-parcelize'
    // hilt plugin
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdk 33

    defaultConfig {
        applicationId "com.raghav.mynotes"
        minSdk 21
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

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

    buildTypes {
        release {
            // Enables code shrinking, obfuscation, and optimization
            minifyEnabled true

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
    }
    buildFeatures{
        viewBinding true
    }

    sourceSets {
        // Adds exported schema location as test app assets.
        getByName("androidTest").assets.srcDir("$projectDir/schemas")
    }
    namespace 'com.raghav.mynotes'
}

dependencies {

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation "androidx.activity:activity-ktx:1.6.0"
    implementation "androidx.fragment:fragment-ktx:1.5.3"

    def lottieVersion = "3.4.0"
    implementation "com.airbnb.android:lottie:$lottieVersion"

    //Room
    implementation "androidx.room:room-runtime:2.4.3"
    kapt "androidx.room:room-compiler:2.4.3"
    implementation("androidx.room:room-ktx:2.4.3")

    // Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'

    // Coroutine Lifecycle Scopes
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"

    //Navigation Components
    implementation "androidx.navigation:navigation-fragment-ktx:2.5.2"
    implementation "androidx.navigation:navigation-ui-ktx:2.5.2"

    //Dagger-Hilt Dependencies
    implementation 'com.google.dagger:hilt-android:2.42'
    kapt 'com.google.dagger:hilt-android-compiler:2.42'

    //room-testing
    androidTestImplementation("androidx.room:room-testing:2.4.3")

    //Library for making assertions in Test Cases
    androidTestImplementation "com.google.truth:truth:1.1.3"

    // Preferences Datastore
    implementation "androidx.datastore:datastore-preferences:1.0.0"

    // Leak Canary (Debug Implementation as this Library should not get included in release build)
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'

    // region Dependencies for Testing

    // for making assertions in Test Cases
    testImplementation "com.google.truth:truth:1.1.3"
    androidTestImplementation "com.google.truth:truth:1.1.3"

    // for testing coroutines
    testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4"
    androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4"

    // AndroidX
    androidTestImplementation "androidx.test:core-ktx:1.4.0"
    testImplementation "androidx.arch.core:core-testing:2.1.0"
    androidTestImplementation "androidx.test.ext:junit-ktx:1.1.3"
    testImplementation "androidx.test.ext:junit-ktx:1.1.3"
    androidTestImplementation 'org.robolectric:robolectric:4.6'
    testImplementation 'org.robolectric:robolectric:4.6'

    // endregion

}

// Allow references to generated code
kapt {
    correctErrorTypes = true
}