buildscript {
    ext.kotlin_version = '1.3.61'
    ext.aws_version = AWS_CORE_SDK_VERSION

    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.amazonaws:aws-android-sdk-appsync-gradle-plugin:3.1.3"
    }
}

allprojects {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        google()
        mavenCentral()
    }
}

subprojects { project ->
    afterEvaluate {
        if (System.getenv("ORG_GRADLE_PROJECT_signingKeyId") != null) {
            System.out.println("Getting signing info from protected source.")
            project.ext.'signing.keyId' = System.getenv("ORG_GRADLE_PROJECT_signingKeyId")
            project.ext.'signing.password' = System.getenv('ORG_GRADLE_PROJECT_signingPassword')
            project.ext.'signing.inMemoryKey' = System.getenv('ORG_GRADLE_PROJECT_signingInMemoryKey')
            project.ext.SONATYPE_NEXUS_USERNAME =  System.getenv('ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME')
            project.ext.SONATYPE_NEXUS_PASSWORD = System.getenv('ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD')
        }
    }
}

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