// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    //https://developer.android.com/jetpack/androidx/releases/compose-kotlin
    ext.kotlin_version = '1.8.10'
    ext.kotlin_compiler_extension_version = '1.4.3'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
plugins {
    id 'com.android.application' version '7.4.1' apply false
    id 'com.android.library' version '7.4.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
def getVersionCode = { ->
    try {
        def stdout = new ByteArrayOutputStream()
        exec {
            commandLine 'git', 'rev-list', '--first-parent', '--count', 'HEAD'
            standardOutput = stdout
        }
        return Integer.parseInt(stdout.toString().trim())
    } catch (ignored) {
        return -1;
    }
}

def getVersionName = { ->
    try {
        def stdout = new ByteArrayOutputStream()
        exec {
            commandLine 'git', 'describe', '--tags', '--dirty'
            standardOutput = stdout
        }

        def versionName = stdout.toString().trim()
        if (versionName.startsWith("v")) {
            return versionName.substring(1)
        } else {
            return versionName
        }
    } catch (ignored) {
        return null;
    }
}
ext {
    gitVersionCode = getVersionCode()
    gitVersionName = getVersionName()
    APPLICATION_ID = "one.yufz.hmspush"

    COMPILE_SDK = 34
    MIN_SDK = 26
    TARGET_SDK = 34
}