// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: '../version.gradle'

buildscript {
    apply from: '../version.gradle'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:$gradleVersion"
    }
}

subprojects {
    afterEvaluate { project ->
        if (project.hasProperty("dependencies")) {
            dependencies {
                implementation "androidx.appcompat:appcompat:$appcompatVersion"
                implementation "com.google.android.material:material:$materialVersion"
                implementation "com.esri.arcgisruntime:arcgis-android:$arcgisVersion"
                implementation "androidx.multidex:multidex:$multidexVersion"
            }
        }
        project.android {
            compileOptions {
                sourceCompatibility rootProject.ext.javaVersion
                targetCompatibility rootProject.ext.javaVersion
            }
            defaultConfig {
                multiDexEnabled true
            }
            packagingOptions {
                exclude 'META-INF/DEPENDENCIES'
            }
        }
    }
}

task apiKey {
    def apiKeyFile = new File("${System.properties.getProperty("user.home")}/.gradle/gradle.properties")
    if (!apiKeyFile.exists()) {
        print("Go to " + new URL("https://developers.arcgis.com/dashboard/") + " to get an API key.")
        print("Add your API Key to ${System.properties.getProperty("user.home")}\\.gradle\\gradle.properties.")
        String apiKeyFileContents = "API_KEY = "
        apiKeyFile.write(apiKeyFileContents)
    }
}
