// Top-level build file where you can add configuration options common to all sub-projects/modules.
Properties properties = new Properties()
File file = new File('release.properties')
if (file.canRead()) {
    properties.load(new FileInputStream(file))
}
   
if (!hasProperty('RELEASE_STORE_FILE')) {
    ext.RELEASE_STORE_FILE='nokeyfile'
}
if (!hasProperty('RELEASE_KEY_ALIAS')) {
    ext.RELEASE_KEY_ALIAS=''
}
if (!hasProperty('RELEASE_KEY_ALIAS')) {
    ext.RELEASE_KEY_ALIAS=''
}
if (!hasProperty('RELEASE_KEY_PASSWORD')) {
    ext.RELEASE_KEY_PASSWORD=''
}

def getVersionName = { ->
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'describe', '--tags'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}

ext {
    versionName = properties.get('VERSION_NAME', getVersionName())
    versionCode = properties.get('VERSION_CODE', 22)
    compileApi = properties.get('COMPILE_API', 30)
    targetApi = properties.get('TARGET_API', 30)
    minApi = properties.get('MIN_API', 21)
    toolsVersion = properties.get('TOOLS_VERSION', '30.0.3')

    println '----------------- Project configuration -------------------'
    println 'VERSION_NAME:       ' + versionName
    println 'VERSION_CODE:       ' + versionCode
    println 'RELEASE_STORE_FILE: ' + RELEASE_STORE_FILE
    println 'RELEASE_KEY_ALIAS:  ' + RELEASE_KEY_ALIAS
    println 'compile API:        ' + compileApi
    println 'target API:         ' + targetApi
    println 'min API:            ' + minApi
    println 'tools version:      ' + toolsVersion
    println '-----------------------------------------------------------'
}

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}
