buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.amazonaws:aws-devicefarm-gradle-plugin:1.3'
        classpath 'com.android.tools.build:gradle:4.0.1'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

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

subprojects { project ->
    afterEvaluate {
        configureAndroidLibrary(project)
    }
}

private void configureAndroidLibrary(Project project) {
    project.android {
        defaultConfig {
            versionName rootProject.findProperty('VERSION_NAME')
            if (project.hasProperty('signingKeyId')) {
                System.out.println("Getting signing info from protected source.")
                project.ext.'signing.keyId' = findProperty('signingKeyId')
                project.ext.'signing.password' = findProperty('signingPassword')
                project.ext.'signing.inMemoryKey' = findProperty('signingInMemoryKey')
            }
        }
    }
}
