ext.deps = [:]

def deps = [:]
deps.androidGradlePlugin = "com.android.tools.build:gradle:${versions.gradle.androidGradlePlugin}"
deps.gradlePluginVersions = "com.github.ben-manes:gradle-versions-plugin:${versions.gradle.gradleVersions}"
deps.kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}"
deps.testinstrunner = "androidx.test.runner.AndroidJUnitRunner"
ext.deps = deps

def androidx = [:]
androidx.appCompat = "androidx.appcompat:appcompat:${versions.appcompat}"
androidx.browser = "androidx.browser:browser:${versions.browser}"
androidx.cardView = "androidx.cardview:cardview:${versions.cardView}"
androidx.constraintLayout =
        "androidx.constraintlayout:constraintlayout:${versions.constraintlayout}"
androidx.coreKtx = "androidx.core:core-ktx:${versions.coreKtx}"
androidx.emoji = "androidx.emoji:emoji:${versions.emoji}"
androidx.emojiAppCompat = "androidx.emoji:emoji-appcompat:${versions.emoji}"
androidx.emojiBundled = "androidx.emoji:emoji-bundled:${versions.emoji}"
androidx.exifInterface = "androidx.exifinterface:exifinterface:${versions.exifInterface}"
androidx.fragmentKtx = "androidx.fragment:fragment-ktx:${versions.fragmentKtx}"
androidx.pagingRuntimeKtx =
        "androidx.paging:paging-runtime-ktx:${versions.pagingRuntimeKtx}"
androidx.preferenceKtx = "androidx.preference:preference-ktx:${versions.preferenceKtx}"
androidx.recyclerView = "androidx.recyclerview:recyclerview:${versions.recyclerView}"
androidx.roomCompiler = "androidx.room:room-compiler:${versions.room}"
androidx.roomRuntime = "androidx.room:room-runtime:${versions.room}"
androidx.roomRxJava = "androidx.room:room-rxjava2:${versions.room}"
androidx.shareTarget = "androidx.sharetarget:sharetarget:${versions.shareTarget}"
androidx.swipeRefreshLayout =
        "androidx.swiperefreshlayout:swiperefreshlayout:${versions.swipeRefreshLayout}"
androidx.viewpager2 = "androidx.viewpager2:viewpager2:${versions.viewpager2}"
androidx.workRuntime = "androidx.work:work-runtime:${versions.workRuntime}"

def lifecycle = [:]
lifecycle.commonJava = "androidx.lifecycle:lifecycle-common-java8:${versions.lifecycle}"
lifecycle.liveDataKtx =
        "androidx.lifecycle:lifecycle-livedata-ktx:${versions.lifecycle}"
lifecycle.reactiveStreamsKtx =
        "androidx.lifecycle:lifecycle-reactivestreams-ktx:${versions.lifecycle}"
lifecycle.viewmodelKtx =
        "androidx.lifecycle:lifecycle-viewmodel-ktx:${versions.lifecycle}"
androidx.lifecycle = lifecycle
deps.androidx = androidx

def dagger = [:]
dagger.dagger = "com.google.dagger:dagger:${versions.dagger}"
dagger.daggerAndroid = "com.google.dagger:dagger-android:${versions.dagger}"
dagger.daggerCompiler = "com.google.dagger:dagger-compiler:${versions.dagger}"
dagger.daggerProcessor = "com.google.dagger:dagger-android-processor:${versions.dagger}"
dagger.daggerSupport = "com.google.dagger:dagger-android-support:${versions.dagger}"
deps.dagger = dagger

def glide = [:]
glide.glide = "com.github.bumptech.glide:glide:${versions.glide}"
glide.glideCompiler = "com.github.bumptech.glide:compiler:${versions.glide}"
glide.glideImage = "com.github.piasy:GlideImageLoader:${versions.glideImage}"
glide.glideImageViewFactory =
        "com.github.piasy:GlideImageViewFactory:${versions.glideImage}"
glide.glideOkhttp = "com.github.bumptech.glide:okhttp3-integration:${versions.glide}"
glide.glidePluginAnimation = "com.github.penfeizhou.android.animation:glide-plugin:${versions.glidePluginAnimation}"
deps.glide = glide

def google = [:]
google.flexbox = "com.google.android:flexbox:${versions.flexbox}"
google.exoplayer = "com.google.android.exoplayer:exoplayer:${versions.exoplayer}"
google.materialDesign = "com.google.android.material:material:${versions.materialDesign}"
deps.google = google

def kotlin = [:]
kotlin.reflect = "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"
kotlin.stdlib = "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
kotlin.stdlibJdk = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
deps.kotlin = kotlin

def kotlinx = [:]
kotlinx.coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.kotlinx}"
kotlinx.coroutinesAndroid = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.kotlinx}"
kotlinx.coroutinesTest = "org.jetbrains.kotlinx:kotlinx-coroutines-test:${versions.kotlinx}"
deps.kotlinx = kotlinx

def rxjava = [:]
rxjava.rxAndroid = "io.reactivex.rxjava2:rxandroid:${versions.rxAndroid}"
rxjava.rxJava = "io.reactivex.rxjava2:rxjava:${versions.rxJava}"
rxjava.rxKotlin = "io.reactivex.rxjava2:rxkotlin:${versions.rxKotlin}"
deps.rxjava = rxjava

def simplestack = [:]
simplestack.lib = "com.github.Zhuinden:simple-stack:${versions.simplestack}"
simplestack.ext = "com.github.Zhuinden:simple-stack-extensions:${versions.simplestackext}"
deps.simplestack = simplestack

def square = [:]
square.retrofit = "com.squareup.retrofit2:retrofit:${versions.retrofit}"
square.retrofitAdapterRxJ2 =
        "com.squareup.retrofit2:adapter-rxjava2:${versions.retrofit}"
square.retrofitConvGson = "com.squareup.retrofit2:converter-gson:${versions.retrofit}"

square.logginInterceptor =
        "com.squareup.okhttp3:logging-interceptor:${versions.okhttpVersion}"
square.okhttp = "com.squareup.okhttp3:okhttp:${versions.okhttpVersion}"
square.okhttpBrotli = "com.squareup.okhttp3:okhttp-brotli:${versions.okhttpVersion}"
deps.square = square

def testing = [:]
testing.extJunit = "androidx.test.ext:junit:${versions.testing.extJunit}"
testing.espresso = "androidx.test.espresso:espresso-core:${versions.testing.espresso}"
testing.junit = "junit:junit:${versions.testing.junit}"
testing.mockitoInline = "org.mockito:mockito-inline:${versions.testing.mockitoInline}"
testing.mockitoKotlin = "com.nhaarman.mockitokotlin2:mockito-kotlin:${versions.testing.mockitoKotlin}"
testing.roboelectric = "org.robolectric:robolectric:${versions.testing.roboelectric}"
testing.roomTesting = "androidx.room:room-testing:${versions.testing.roomTesting}"
deps.testing = testing

deps.androidSvg = "com.caverock:androidsvg-aar:${versions.androidSvg}"
deps.androidImageCropper =
        "com.theartofdev.edmodo:android-image-cropper:${versions.androidImageCropper}"
deps.autodispose = "com.uber.autodispose:autodispose:${versions.autodispose}"
deps.autodisposeAndroidArchComp =
        "com.uber.autodispose:autodispose-android-archcomponents:${versions.autodispose}"
deps.bigImageViewer = "com.github.piasy:BigImageViewer:${versions.bigImageViewer}"
deps.conscryptAndroid = "org.conscrypt:conscrypt-android:${versions.conscryptAndroid}"
deps.filemojiCompat = "de.c1710:filemojicompat:${versions.filemojiCompat}"
deps.fragmentviewbindingdelegateKt =
        "com.github.Zhuinden:fragmentviewbindingdelegate-kt:${versions.fragmentviewbindingdelegateKt}"
deps.markdownEdit = "com.github.Tunous:MarkdownEdit:${versions.markdownEdit}"
deps.materialDrawer = "com.mikepenz:materialdrawer:${versions.materialDrawer}"
deps.materialDrawerIconics =
        "com.mikepenz:materialdrawer-iconics:${versions.materialDrawer}"
deps.materialDrawerTypeface =
        "com.mikepenz:google-material-typeface:${versions.materialDrawerTypeface}"
deps.sparkButton = "com.github.connyduck:sparkbutton:${versions.sparkButton}"
deps.timber = "com.jakewharton.timber:timber:${versions.timber}"

// Repository handler
static def addRepos(RepositoryHandler handler) {
    handler.mavenCentral()
    handler.google()
    handler.gradlePluginPortal()
    handler.maven { url "https://jitpack.io" }
    handler.maven { url "https://plugins.gradle.org/m2/" }
}

static def isNonStable(String version) {
    def stableKeyword = ["a", "alpha", "b", "beta", "final", "ga", "m", "release", "rc"].any { it -> version.toLowerCase().contains(it) }
    return stableKeyword
}

ext.isNonStable = this.&isNonStable
ext.addRepos = this.&addRepos
