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

android {
    compileSdkVersion 30
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.ersiver.newsster"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "com.ersiver.newsster.CustomTestRunner"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }

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

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

    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'
    }

    buildFeatures {
        viewBinding = true
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])

    // Kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // AndroidX
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.3'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.test.espresso:espresso-idling-resource:3.3.0'
    implementation 'com.android.support.test.espresso.idling:idling-net:3.0.2'

    // Material Components
    implementation 'com.google.android.material:material:1.3.0'

    //Glide
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'androidx.preference:preference-ktx:1.1.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

    //Retrofit
    def version_retrofit = "2.9.0"
    implementation "com.squareup.retrofit2:retrofit:$version_retrofit"
    implementation "com.squareup.retrofit2:converter-moshi:$version_retrofit"

    //Retrofit coroutine adapter
    def version_retrofit_coroutines_adapter = "0.9.2"
    implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$version_retrofit_coroutines_adapter"

    //Network
    def okhttpLoggingInterceptorVersion = '4.7.2'
    implementation "com.squareup.okhttp3:logging-interceptor:$okhttpLoggingInterceptorVersion"

    // Moshi
    def version_moshi = "1.9.2"
    implementation "com.squareup.moshi:moshi:$version_moshi"
    implementation "com.squareup.moshi:moshi-kotlin:$version_moshi"

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

    // Room dependency
    def room_version = "2.3.0-beta02"
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"
    //Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:$room_version"

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

    //Paging
    def paging_version = "3.0.0-beta01"
    implementation "androidx.paging:paging-runtime-ktx:$paging_version"

    //Hilt
    def hilt_version = "2.31-alpha"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
    implementation "com.google.dagger:hilt-android:$hilt_version"
    implementation 'androidx.hilt:hilt-navigation-fragment:1.0.0-alpha03'

    //Hilt-navigation
    implementation 'androidx.hilt:hilt-navigation-fragment:1.0.0-alpha03'

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

    //Local test
    testImplementation 'junit:junit:4.12'
    testImplementation 'com.squareup.okhttp3:mockwebserver:4.7.2'
    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8'
    testImplementation 'androidx.arch.core:core-testing:2.1.0'
    testImplementation 'org.mockito:mockito-core:3.3.3'
    testImplementation 'org.mockito:mockito-inline:3.3.3'
    testImplementation 'androidx.test:core-ktx:1.3.0'
    testImplementation 'androidx.test.ext:junit:1.1.2'
    testImplementation 'androidx.test:core-ktx:1.3.0'
    testImplementation 'androidx.test.ext:junit:1.1.2'

    //Instrumented test
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8'
    androidTestImplementation 'androidx.arch.core:core-testing:2.1.0'
    androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'com.linkedin.dexmaker:dexmaker-mockito:2.28.0'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'

    debugImplementation 'androidx.fragment:fragment-testing:1.3.0'
    implementation 'androidx.test:core:1.3.0'

    // Hilt testing dependency
    androidTestImplementation "com.google.dagger:hilt-android-testing:$hilt_version"
    kaptAndroidTest "com.google.dagger:hilt-android-compiler:$hilt_version"
}
