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

buildscript {
    repositories {
        // remove next line after Android Gradle Plugin 3.6.0+ is stable
        maven { url "http://storage.googleapis.com/r8-releases/raw/master"}
        google()
        jcenter()
    }
    dependencies {
        // remove next line after Android Gradle Plugin 3.6.0+ is stable
        classpath Deps.tools_newestR8
        classpath Deps.tools_androidgradle
        classpath Deps.tools_kotlingradle
        classpath Deps.androidx_safeargs
        classpath Deps.allopen
        classpath Deps.osslicenses_plugin

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

plugins {
    id("io.gitlab.arturbosch.detekt").version("1.0.0-RC16")
}

allprojects {
    repositories {
        google()
        maven {
            url "https://snapshots.maven.mozilla.org/maven2"
        }
        maven {
            url "https://maven.mozilla.org/maven2"
        }
        maven {
            url "https://repo.leanplum.com/"
        }
        jcenter()
    }
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
        kotlinOptions.jvmTarget = "1.8"
        kotlinOptions.allWarningsAsErrors = true
        kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental", "-Xskip-runtime-version-check"]
    }
}

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

detekt {
    // The version number is duplicated, please refer to plugins block for more details
    version = "1.0.0-RC16"
    input = files("$projectDir/app/src", "$projectDir/architecture/src")
    config = files("$projectDir/config/detekt.yml")
    filters = ".*test.*,.*/resources/.*,.*/tmp/.*"

    reports {
        html {
            enabled = true
            destination = file("$projectDir/build/reports/detekt.html")
        }
        xml {
            enabled = false
        }
    }
}

configurations {
    ktlint
}

dependencies {
    ktlint "com.pinterest:ktlint:0.34.2"
}

task ktlint(type: JavaExec, group: "verification") {
    description = "Check Kotlin code style."
    classpath = configurations.ktlint
    main = "com.pinterest.ktlint.Main"
    args "app/src/**/*.kt", "architecture/src/**/*.kt"
}
