// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
    def versionMajor = 1
    def versionMinor = 3
    def versionPatch = 0
    def versionCode = versionPatch + versionMinor * 100 + versionMajor * 10000

    androidConfig = [
            compileSdkVersion        : 28,
            minSdkVersion            : 16,
            targetSdkVersion         : 28,
            versionCode              : versionCode,
            versionName              : "${versionMajor}.${versionMinor}.${versionPatch}",

            testInstrumentationRunner: "androidx.test.runner.AndroidJUnitRunner"
    ]
}

buildscript {
    ext {
        depPaths = {
            def versions = [
                    gradlePlugin  : '4.2.1',
                    androidJunit5 : '1.6.2.0',
                    versions      : '0.36.0',
                    kotlin        : '1.5.10',
                    coroutines    : '1.5.0',
                    appCompat     : '1.2.0',
                    material      : '1.2.0',
                    workManager   : '2.4.0',

                    junit         : '4.12',
                    junitAnd      : '1.1.2-rc03',
                    spek          : '2.0.14',
                    mockk         : '1.10.2',
                    hamkrest      : '1.8.0.1',
                    mockitoKotlin : '1.5.0',
                    mockitoAndroid: '2.8.47',
                    espresso      : '3.3.0-rc03',
            ]

            [
                    gradlePlugin  : "com.android.tools.build:gradle:$versions.gradlePlugin",
                    kotlinPlugin  : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin",
                    androidJunit5 : "de.mannodermaus.gradle.plugins:android-junit5:$versions.androidJunit5",
                    versionsPlugin: "com.github.ben-manes:gradle-versions-plugin:$versions.versions",

                    kotlinStd     : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin",
                    kotlinReflect : "org.jetbrains.kotlin:kotlin-reflect:$versions.kotlin",
                    kotlinTestJ5  : "org.jetbrains.kotlin:kotlin-test-junit5:$versions.kotlin",
                    coroutines    : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.coroutines",
                    coroutinesTest: "org.jetbrains.kotlinx:kotlinx-coroutines-test:$versions.coroutines",
                    coroutinesAnd : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.coroutines",
                    appCompat     : "androidx.appcompat:appcompat:$versions.appCompat",
                    material      : "com.google.android.material:material:$versions.material",
                    workManager   : "androidx.work:work-runtime:$versions.workManager",

                    junit         : "junit:junit:$versions.junit",
                    junitAnd      : "androidx.test.ext:junit:$versions.junitAnd",
                    spekDsl       : "org.spekframework.spek2:spek-dsl-jvm:$versions.spek",
                    spekRunner    : "org.spekframework.spek2:spek-runner-junit5:$versions.spek",
                    mockk         : "io.mockk:mockk:$versions.mockk",
                    hamkrest      : "com.natpryce:hamkrest:$versions.hamkrest",
                    mockitoKotlin : "com.nhaarman:mockito-kotlin-kt1.1:$versions.mockitoKotlin",
                    mockitoAndroid: "org.mockito:mockito-android:$versions.mockitoAndroid",
                    espressoCore  : "androidx.test.espresso:espresso-core:$versions.espresso",
            ]
        }()
    }

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath depPaths.gradlePlugin
        classpath depPaths.kotlinPlugin
        classpath depPaths.androidJunit5
        classpath depPaths.versionsPlugin

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

apply plugin: "com.github.ben-manes.versions"

allprojects {
    repositories {
        google()
        jcenter()
    }

    if (!project.name.contains("sample")) {
        // https://youtrack.jetbrains.com/issue/KT-37652
        tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
            kotlinOptions {
                freeCompilerArgs += '-Xexplicit-api=strict'
            }
        }
    }
}

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