// Load credentials for VSTS Maven
project.ext.vstsUsername = System.getenv("ENV_VSTS_MVN_ANDROID_MSAL_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_ANDROID_MSAL_USERNAME") : project.findProperty("vstsUsername")
project.ext.vstsPassword = System.getenv("ENV_VSTS_MVN_ANDROID_MSAL_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_ANDROID_MSAL_ACCESSTOKEN") : project.findProperty("vstsMavenAccessToken")

buildscript {
    apply from: rootProject.file("gradle/versions.gradle")

    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.ext.kotlinVersion}"
        classpath "com.android.tools.build:gradle:$rootProject.ext.gradleVersion"
    }
}

allprojects {
    repositories {
        google()
        mavenLocal()
        mavenCentral()
        // Adding here because Travis cannot access AndroidADAL feed.
        maven {
            url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
            name 'Duo-SDK-Feed'
        }
        maven {
            name "vsts-maven-adal-android"
            url "https://identitydivision.pkgs.visualstudio.com/_packaging/AndroidADAL/maven/v1"
            credentials {
                username project.vstsUsername
                password project.vstsPassword
            }
        }
    }

    dependencyLocking {
        lockAllConfigurations()
    }
}

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