plugins {
    id 'com.android.application'
}

android {
    compileSdk 35
    namespace 'in.hridayan.ashell'

    defaultConfig {
        applicationId "in.hridayan.ashell"
        minSdk 26
        targetSdk 35
        versionCode 55
        versionName "v6.1.0"

        ndk.abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
    }

    lint {
        baseline = file("lint-baseline.xml")
    }

    signingConfigs {
        release {
            if (System.getenv("CI") == "true") {
                def keystorePath = System.getenv("KEYSTORE_PATH")
                if (keystorePath != null) {
                    storeFile file(keystorePath)
                    storePassword System.getenv("KEYSTORE_PASSWORD")
                    keyAlias System.getenv("KEY_ALIAS")
                    keyPassword System.getenv("KEY_PASSWORD")
                }
            }
        }
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
        }

        release {
            def config = System.getenv("CI") ? "release" : "debug"
            signingConfig signingConfigs.findByName(config)
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    applicationVariants.configureEach { variant ->
        variant.outputs.configureEach { output ->
            outputFileName = "aShell You ${variant.versionName}-${variant.buildType.name}.apk"
        }
    }

    buildFeatures {
        buildConfig = true
        viewBinding true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    androidResources { generateLocaleConfig true }
    packagingOptions.jniLibs.useLegacyPackaging = true
}

dependencies {
    implementation libs.gson
    implementation libs.material
    implementation libs.lifecycle.viewmodel
    implementation libs.work.runtime
    implementation libs.preference
    implementation libs.shizuku.api
    implementation libs.shizuku.provider
    implementation libs.libsu.core
    implementation libs.glide
    annotationProcessor libs.glide.compiler
    implementation libs.lottie
    implementation libs.javax.annotation
    implementation libs.circleimageview

    implementation project(':adblib')
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    testImplementation libs.junit
}
