//file:noinspection UnnecessaryQualifiedReference, GrDeprecatedAPIUsage
apply plugin: 'com.android.application'

android {

    compileSdk 34
    buildFeatures {
        viewBinding true
    }
    dependenciesInfo {
        includeInApk true
        includeInBundle true
    }
    buildToolsVersion '34.0.0'
    ndkVersion '25.1.8937393'
}
android.buildFeatures.buildConfig true
android.namespace 'com.termux.shell'
android.defaultConfig.minSdkVersion 21
android.defaultConfig.applicationId 'com.termux'
android.buildTypes.debug.signingConfig null
android.buildFeatures.buildConfig true
android.compileOptions.sourceCompatibility JavaVersion.VERSION_1_8
android.compileOptions.targetCompatibility JavaVersion.VERSION_1_8
dependencies.compileOnly project(':shell-loader:stub')
android.applicationVariants.configureEach { outputs.configureEach { outputFileName = "shell-loader-debug.apk" } }

def signingConfig = project(':app').android.signingConfigs.debug
def keyStore = java.security.KeyStore.getInstance(java.security.KeyStore.getDefaultType())
keyStore.load(new FileInputStream(signingConfig.storeFile), signingConfig.keyPassword.toCharArray())

android.defaultConfig.buildConfigField "String", "logTag", "\"Termux:x11 loader\""
android.defaultConfig.buildConfigField "int", "SIGNATURE", String.valueOf(Arrays.hashCode(keyStore.getCertificate(signingConfig.keyAlias).getEncoded()))
android.defaultConfig.buildConfigField "String", "CLASS_ID", "\"com.termux.x11.CmdEntryPoint\""
android.defaultConfig.buildConfigField "String", "packageNotInstalledErrorText",
        """\"Termux:X11 application is not found.\" +
        \"You should choose latest successful workflow here: https://github.com/termux/termux-x11/actions/workflows/debug_build.yml\" +
        \"After this you should download \\"termux-x11-ARCH-debug\\" or \\"termux-x11-universal-debug\\" artifact and install apk contained in this zip file.\""""
android.defaultConfig.buildConfigField "String", "packageSignatureMismatchErrorText",
        "\"Signature verification of target application " + android.namespace + " failed.\\nPlease, reinstall both termux-x11 package and Termux:X11 application from the same source\""
android.defaultConfig.buildConfigField "String", "COMMIT", "\"" + ("git rev-parse HEAD\n".execute().getText().trim() ?: (System.getenv('CURRENT_COMMIT') ?: "NO_COMMIT")) + "\""
