// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.6.10'

    ext {
        // global variables
        compile_sdk_version = 31
        min_sdk_version = 21

        // local variables (use def)
        def androidx_test_version = '1.4.0'
        def annotations_version = '1.3.0'
        def appcompat_version = '1.4.1'
        def arch_version = '2.1.0'
        def constraint_layout_version = '2.1.3'
        def coroutines_android_version = '1.6.0'
        def espresso_version = '3.4.0'
        def glide_version = '4.13.0'
        def gson_version = '2.8.8'
        def junit_version = '4.13.2'
        def lifecycle_version = '2.4.1'
        def material_version = '1.5.0'
        def retrofit_version = '2.9.0'
        def room_version = '2.4.1'
        def truth_version = '1.0'
        def work_version = '2.7.0'

        libraries = [
                // Coroutines
                "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_android_version",
                "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_android_version",

                // Android UI and appcompat
                "androidx.appcompat:appcompat:$appcompat_version",
                "com.google.android.material:material:$material_version",
                "androidx.constraintlayout:constraintlayout:$constraint_layout_version",
                "androidx.fragment:fragment-ktx:1.1.0",

                // Glide
                "com.github.bumptech.glide:glide:$glide_version",

                // ViewModel and LiveData
                "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version",
                "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version",

                // network & serialization
                "com.google.code.gson:gson:$gson_version",
                "com.squareup.retrofit2:converter-gson:$retrofit_version",
                "com.squareup.retrofit2:retrofit:$retrofit_version",

                // threading
                "androidx.annotation:annotation:$annotations_version"
        ]

        arch_libraries = [
                "androidx.work:work-runtime-ktx:$work_version",

                // Room for database
                "androidx.room:room-ktx:$room_version"
        ]

        librariesKapt = [
                "androidx.room:room-compiler:$room_version",
                "com.github.bumptech.glide:compiler:$glide_version"
        ]

        testLibraries = [
                "junit:junit:$junit_version",
                // Coroutines testing
                "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_android_version",

                // mocks
                "org.mockito:mockito-core:2.23.0",

                //  Architecture Components testing libraries
                "androidx.arch.core:core-testing:$arch_version",

                "com.google.truth:truth:$truth_version",
        ]

        androidTestLibraries = [
                "junit:junit:$junit_version",
                "androidx.test:runner:$androidx_test_version",
                "androidx.test:rules:$androidx_test_version",

                // Espresso
                "androidx.test.espresso:espresso-core:$espresso_version",
                "androidx.test.espresso:espresso-contrib:$espresso_version",
                "androidx.test.espresso:espresso-intents:$espresso_version",

                //  Architecture Components testing libraries
                "androidx.arch.core:core-testing:$arch_version",
                "androidx.work:work-testing:$work_version",
        ]
    }

    repositories {
        google()
       mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
