plugins {
    id 'com.gladed.androidgitversion' version '0.4.14'
}

androidGitVersion {
    abis = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3, "riscv64":4, 'mips':5, 'mips64':6, 'x86':8, 'x86_64':9 ]
    prefix ''
}

println 'Version Name: ' + androidGitVersion.name()
println 'Version Code: ' + androidGitVersion.code()

apply plugin: 'com.android.application'
android {
    compileSdkVersion = rootProject.ext.compileApi
    buildToolsVersion = rootProject.ext.toolsVersion

    defaultConfig {
        applicationId "com.freerdp.afreerdp"
        minSdkVersion rootProject.ext.minApi
        targetSdkVersion rootProject.ext.targetApi
        versionName = androidGitVersion.name()
        versionCode = androidGitVersion.code()
    }

    splits {
        abi {
            enable true
            reset()
            include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
            universalApk true
        }
    }
    
    signingConfigs {
        release {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
            storeType "jks"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            jniDebuggable true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    applicationVariants.configureEach { variant ->
        variant.outputs.each { output ->
            def baseAbiVersionCode = project.androidGitVersion.abis.get(output.getFilter(com.android.build.OutputFile.ABI))
            if (baseAbiVersionCode != null) {
                output.versionCodeOverride = (10 * project.android.defaultConfig.versionCode) + baseAbiVersionCode
            } else {
                output.versionCodeOverride = 10 * project.android.defaultConfig.versionCode
            }
        }
    }
}

dependencies {
    implementation project(':freeRDPCore')
}
