buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:1.0.2'
        classpath 'de.timfreiheit.resourceplaceholders:placeholders:0.3'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
    }

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint"
        }
    }
}

// Disable predex if requested (we can"t predex in Circle CI
// See http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance
// and https://circleci.com/docs/android
project.ext.preDexLibs = !project.hasProperty("disablePreDex")

subprojects {
    project.plugins.whenPluginAdded { plugin ->
        if ("com.android.build.gradle.AppPlugin" == plugin.class.name) {
            project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
        } else if ("com.android.build.gradle.LibraryPlugin" == plugin.class.name) {
            project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
        }
    }
}

project.ext {
    compileSdkVersion = 28
    minSdkVersion = 16
    targetSdkVersion = 28

    // AndroidX
    annotationVersion = "1.1.0"
    appcompatVersion = "1.1.0"
    mediaVersion = "1.1.0"
    preferenceVersion = "1.1.1"
    workManagerVersion = "2.3.4"
    googleMaterialVersion = "1.1.0"

    // Third-party
    commonslangVersion = "3.6"
    commonsioVersion = "2.5"
    jsoupVersion = "1.11.2"
    glideVersion = "4.8.0"
    okhttpVersion = "3.12.10"
    okioVersion = "1.17.5"
    eventbusVersion = "3.2.0"
    rxAndroidVersion = "2.1.1"
    rxJavaVersion = "2.2.2"
    iconifyVersion = "2.2.2"
    audioPlayerVersion = "v1.0.17"

    // Google Play build
    wearableSupportVersion = "2.6.0"

    //Tests
    awaitilityVersion = "3.1.6"
    robotiumSoloVersion = "5.6.3"
    espressoVersion = "3.2.0"
    runnerVersion = "1.2.0"
    rulesVersion = "1.2.0"
}

wrapper {
    gradleVersion = "6.3"
}

// free build hack: common functions
def doFreeBuild() {
    return hasProperty("freeBuild")
}

apply plugin: "checkstyle"
checkstyle {
    toolVersion '8.24'
}

task checkstyle(type: Checkstyle) {
    classpath = files()
    source "${project.rootDir}"
    exclude("**/gen/**")
    exclude("**/generated/**")
}