plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
}


def apikeyPropertiesFile = rootProject.file("apikey.properties")
def properties = new Properties()
properties.load(new FileInputStream(apikeyPropertiesFile))

android {
    signingConfigs {
        release {
            storeFile file('/Users/akshay/nytimescompose.jks')
            storePassword properties['STORE_PASSWORD']
            keyAlias properties['KEY_ALIAS']
            keyPassword properties['KEY_PASSWORD']
        }
    }

    compileSdk 33

    defaultConfig {
        applicationId "io.ak1.nytimes"
        minSdk 21
        targetSdk 33
        versionCode 2
        versionName "1.0.1"
        multiDexEnabled true
        javaCompileOptions {
            annotationProcessorOptions {
                arguments += [
                        "room.schemaLocation"  : "$projectDir/schemas".toString(),
                        "room.incremental"     : "true",
                        "room.expandProjection": "true"]
            }
        }
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
        defaultConfig {
            // should correspond to key/value pairs inside the file
            buildConfigField("String", "API_KEY", properties['API_KEY'])
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = "11"
        useIR = true
    }
    sourceSets {
        androidTest.java.srcDirs += "src/test-common/java"
        test.java.srcDirs += "src/test-common/java"
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion kotlinCExtVer
    }
}

dependencies {
    // Core
    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'com.google.android.material:material:1.6.1'

    // Shimmer
    implementation 'com.facebook.shimmer:shimmer:0.5.0'

    //Compose
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"


    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'
    implementation 'androidx.activity:activity-compose:1.6.0'
    implementation 'androidx.navigation:navigation-compose:2.5.2'
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
    def accompanist = '0.15.0'
    implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist"
    implementation "com.google.accompanist:accompanist-coil:$accompanist"

    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"

    // Multidex
    def multidex_version = "2.0.1"
    implementation "androidx.multidex:multidex:$multidex_version"

    // Retrofit
    def retrofit_version = "2.9.0"
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.8'
    implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.8'

    //Koin
    implementation "io.insert-koin:koin-android:$koin_version"

    //Android Components
    // Room
    def room_version = '2.4.3'
    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    // optional - Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:$room_version"

    // LifeCycle
    def lifecycle_version = '2.4.1'
    // ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    // LiveData
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"

    // Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.2'
    //Datastore Preferences
    implementation('androidx.datastore:datastore-preferences:1.0.0')
    // WorkManager
    def work_version = '2.8.0-alpha02'
    implementation "androidx.work:work-runtime-ktx:$work_version"

    // Splash Screen
    implementation 'androidx.core:core-splashscreen:1.0.0'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}