buildscript {
    repositories {
        google()
        mavenCentral()
//        maven { url 'https://plugins.gradle.org/m2' }
//        maven { url 'https://jitpack.io' }
        maven {
            url 'https://api.mapbox.com/downloads/v2/releases/maven'

            credentials {
                username = 'mapbox'
                password = "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg"
                if (password == null || password == "") {
                    throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.")
                }
            }
            authentication {
                basic(BasicAuthentication)
            }
        }
    }
    dependencies {
        classpath "com.mapbox.gradle.plugins:access-token:0.4.0"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://plugins.gradle.org/m2' }
        maven {
            url 'https://api.mapbox.com/downloads/v2/releases/maven'
            authentication {
                basic(BasicAuthentication)
            }
            credentials {
                username = 'mapbox'
                password = "sk.eyJ1IjoicndhaWQiLCJhIjoiY2x6NWo0bTMzMWZodzJrcGZpemYzc3Z4dSJ9.uSSZuwNSGCcCdPAiORECmg"
                if (password == null || password == "") {
                    throw new GradleException("MAPBOX_DOWNLOADS_TOKEN isn't set. Set it to the project properties or to the enviroment variables.")
                }
            }
        }
    }
}

rootProject.layout.buildDirectory = file('../build')
subprojects {
    project.layout.buildDirectory = file("${rootProject.layout.buildDirectory.get().asFile}/${project.name}")
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.layout.buildDirectory
}
