/**
 * Shared file between builds so that they can all use the same dependencies and
 * maven repositories.
 **/
ext.deps = [:]

// version
def versions = [:]
versions.kotlin = "1.4.0"
versions.firebase = "17.5.0"
versions.firestore = "21.6.0"
versions.messaging = "20.2.4"
versions.lifecycle = "2.2.0"
versions.coroutine = "1.3.9"
versions.navigation = "2.3.0"
versions.timber = "4.7.1"
versions.browser = "1.2.0"
versions.hilt = "2.28.3-alpha"
versions.hilt_view_model = "1.0.0-alpha02"
versions.glide = "4.11.0"
versions.oss_license = "0.10.2"
deps.versions = versions

// dependency
def deps = [:]

// androidx
def androidx = [:]
androidx.appcompat = "androidx.appcompat:appcompat:1.1.0"
androidx.core_ktx = "androidx.core:core-ktx:1.3.1"
androidx.constraintlayout = "androidx.constraintlayout:constraintlayout:1.1.3"
androidx.lifecycle = [
        runtime_ktx  : "androidx.lifecycle:lifecycle-runtime-ktx:$versions.lifecycle",
        extensions   : "androidx.lifecycle:lifecycle-extensions:$versions.lifecycle",
        viewmodel_ktx: "androidx.lifecycle:lifecycle-viewmodel-ktx:$versions.lifecycle",
        livedata_ktx : "androidx.lifecycle:lifecycle-livedata-ktx:$versions.lifecycle"
]
androidx.navigation = [
        fragment_ktx: "androidx.navigation:navigation-fragment-ktx:$versions.navigation",
        ui_ktx      : "androidx.navigation:navigation-ui-ktx:$versions.navigation"
]
androidx.material = "com.google.android.material:material:1.1.0"
androidx.swiperefresh = "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
androidx.browser = "androidx.browser:browser:$versions.browser"
deps.androidx = androidx

// kotlin
def kotlin = [:]
kotlin.stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlin"
kotlin.coroutines = [
        core         : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.coroutine",
        android      : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.coroutine",
        play_services: "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$versions.coroutine",
        test         : "org.jetbrains.kotlinx:kotlinx-coroutines-test:$versions.coroutine"
]
deps.kotlin = kotlin

// firebase
deps.firebase = [
        core     : "com.google.firebase:firebase-core:$versions.firebase",
        analytics: "com.google.firebase:firebase-analytics:$versions.firebase",
        firestore: "com.google.firebase:firebase-firestore:$versions.firestore",
        messaging: "com.google.firebase:firebase-messaging:$versions.messaging"
]

// Hilt
deps.hilt = [
        android             : "com.google.dagger:hilt-android:$versions.hilt",
        compiler            : "com.google.dagger:hilt-android-compiler:$versions.hilt",
        view_model          : "androidx.hilt:hilt-lifecycle-viewmodel:$versions.hilt_view_model",
        view_model_compiler : "androidx.hilt:hilt-compiler:$versions.hilt_view_model"
]

deps.google = [
        gson: 'com.google.code.gson:gson:2.8.6',
        flexbox: 'com.google.android:flexbox:2.0.1'
]

// debugging
deps.debugging = [
        timber      : "com.jakewharton.timber:timber:$versions.timber"
]

// Glide
deps.glide = [
        glide   : "com.github.bumptech.glide:glide:$versions.glide",
        compiler: "com.github.bumptech.glide:compiler:$versions.glide"
]

// test
deps.atsl = [
        junit        : "junit:junit:4.12",
        ext_junit    : "androidx.test.ext:junit:1.1.1",
        espresso_core: "androidx.test.espresso:espresso-core:3.2.0"
]

// play services
deps.play_services = [
        oss_license     : "com.google.android.gms:play-services-oss-licenses:17.0.0"
]
ext.deps = deps

// build gradle plugin
def gradlePlugin = [
        android             : "com.android.tools.build:gradle:4.0.1",
        kotlin              : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin",
        play_services       : "com.google.gms:google-services:4.3.3",
        navigation_safe_args: "androidx.navigation:navigation-safe-args-gradle-plugin:$versions.navigation",
        hilt                : "com.google.dagger:hilt-android-gradle-plugin:$versions.hilt",
        oss_license         : "com.google.android.gms:oss-licenses-plugin:$versions.oss_license"
]
ext.gradlePlugin = gradlePlugin

// build_versions
ext.build_versions = [
        compile_sdk: 29,
        build_tools: "29.0.2",
        min_sdk    : 23,
        target_sdk : 29
]

// repository
def static addRepos(RepositoryHandler handler) {
    handler.google()
    handler.jcenter()
}

ext.addRepos = this.&addRepos
