apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'


android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.ersiver.gymific"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "com.ersiver.gymific.CustomTestRunner"
    }

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

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/AL2.0'
        exclude 'META-INF/LGPL2.1'
    }

    sourceSets {
        androidTest.java.srcDirs += "src/test-common/java"
        test.java.srcDirs += "src/test-common/java"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }

    buildFeatures {
        dataBinding true
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.preference:preference:1.1.1'
    implementation 'androidx.fragment:fragment-ktx:1.2.5'

    def lifecycle_version = "2.2.0"
    // Lifecycle
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"

    // Navigation
    def nav_version = "2.3.2"
    implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    implementation "androidx.navigation:navigation-ui:$nav_version"

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

    //Hilt
    def hilt_version = "2.28.3-alpha"
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"

    //Inject ViewModel and WorkManager objects with Hilt
    def hilt_version_vm = "1.0.0-alpha02"
    implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_version_vm"
    implementation "androidx.hilt:hilt-work:$hilt_version_vm"
    kapt "androidx.hilt:hilt-compiler:$hilt_version_vm"

    // Preferences DataStore
    def datastore_version = "1.0.0-alpha05"
    implementation "androidx.datastore:datastore-preferences:$datastore_version"

    // Timber
    implementation 'com.jakewharton.timber:timber:4.7.1'

    //Glide
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    kapt 'com.github.bumptech.glide:compiler:4.11.0'

    //WorkManager
    def work_version = "2.4.0"
    implementation "androidx.work:work-runtime-ktx:$work_version"

    //Gson
    def gsonVersion = "2.8.6"
    implementation "com.google.code.gson:gson:$gsonVersion"

    //Espresso idling resource
    def espressoVersion = "3.3.0"
    implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"

    //Device tests
    androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
    androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion"
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.arch.core:core-testing:2.1.0'
    androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8'
    androidTestImplementation 'androidx.work:work-testing:2.4.0'

    def hiltTestVersion = "2.28.3-alpha"
    androidTestImplementation "com.google.dagger:hilt-android-testing:$hiltTestVersion"
    kaptAndroidTest "com.google.dagger:hilt-android-compiler:$hiltTestVersion"

    // debugImplementation required vs testImplementation: https://issuetracker.google.com/issues/128612536
    debugImplementation("androidx.fragment:fragment-testing:1.2.5") {
        exclude group:'androidx.test', module:'monitor'
    }

    //Local tests
    testImplementation 'androidx.arch.core:core-testing:2.1.0'
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8'
    testImplementation 'org.mockito:mockito-core:3.3.3'
    testImplementation 'org.mockito:mockito-inline:3.3.3'
}