plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'kotlin-parcelize'
    id 'dagger.hilt.android.plugin'
    id 'com.google.devtools.ksp' version '1.6.10-1.0.2'
}

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

android {
    compileSdk 33

    defaultConfig {
        applicationId "com.ericg.neatflix"
        minSdk 26
        targetSdk 33
        versionCode 4
        versionName "v1.0-rc"

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

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

        buildConfigField("String", "NEATFLIX_API_KEY", apikeyProperties['NEATFLIX_API_KEY'])
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources 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'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
    kapt {
        correctErrorTypes = true
    }
}
kotlin {
    sourceSets {
        debug {
            kotlin.srcDir("build/generated/ksp/debug/kotlin")
        }
        release {
            kotlin.srcDir("build/generated/ksp/release/kotlin")
        }
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.8.0'
    implementation "androidx.compose.ui:ui:1.3.0-alpha01"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.0'
    implementation 'androidx.activity:activity-compose:1.5.0'
    testImplementation 'junit:junit:4.13.2'
    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"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"

    // Material Icons
    implementation "androidx.compose.material:material-icons-extended:1.1.1"

    // Constraint Layout
    implementation "androidx.constraintlayout:constraintlayout-compose:$constraintlayoutVersion"

    // Accompanist
    implementation "com.google.accompanist:accompanist-systemuicontroller:0.24.5-alpha"

    // Landscapist image loader
    implementation "com.github.skydoves:landscapist-coil:$landscapistVersion"

    // RatingBar
    implementation 'com.github.a914-gowtham:compose-ratingbar:1.2.3'

    // Timber
    implementation "com.jakewharton.timber:timber:$timberVersion"

    // Stetho
    implementation 'com.facebook.stetho:stetho:1.6.0'
    implementation 'com.facebook.stetho:stetho-okhttp3:1.6.0'

    // Lottie
    implementation "com.airbnb.android:lottie-compose:$lottieVersion"

    // RaamCosta Navigation
    implementation 'io.github.raamcosta.compose-destinations:core:1.4.0-beta'
    ksp 'io.github.raamcosta.compose-destinations:ksp:1.4.0-beta'

    // Hilt
    implementation "com.google.dagger:hilt-android:$hiltVersion"
    kapt "com.google.dagger:hilt-android-compiler:2.38.1"
    implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"
    kapt "androidx.hilt:hilt-compiler:1.0.0"

    // Hilt - for @HiltViewModel
    implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'

    // Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.2"
    implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2"

    // Coroutines
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'

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

    // Pagination
    implementation "androidx.paging:paging-compose:1.0.0-alpha15"

    //Prefs Datastore
    implementation("androidx.datastore:datastore-preferences:1.0.0")

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