plugins {
    id 'com.android.application'
}

def releaseTime() {
    return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}

def appName() {
    return "AdbLoopbackController"
}

android {
    namespace 'com.ttstd.adbloopback'
    compileSdk 34

    defaultConfig {
        applicationId "com.ttstd.adbloopback"
        minSdk 24
        targetSdk 34
        versionCode 1
        versionName "1.0"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    buildFeatures {
        buildConfig true
    }

    signingConfigs {
        keypub {
            storeFile file(rootProject.ext.signingConfigs.keypub.storeFile)
            storePassword rootProject.ext.signingConfigs.keypub.storePassword
            keyAlias rootProject.ext.signingConfigs.keypub.keyAlias
            keyPassword rootProject.ext.signingConfigs.keypub.keyPassword
        }
    }

    buildTypes {
        debug {
            versionNameSuffix "_debug"
            debuggable true
            minifyEnabled false
            signingConfig signingConfigs.keypub
        }

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.keypub
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def buildType = variant.buildType.name
            def fileName = (buildType.contains("debug"))
                    ? "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk"
                    : "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk"
            output.outputFileName = fileName
        }
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.11.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
}
