//****************************************
//************ app 壳的配置文件 ************
//****************************************

import com.quyunshuo.androidbaseframemvvm.buildsrc.*

plugins {
    alias(libs.plugins.application)
    alias(libs.plugins.kotlin)
    alias(libs.plugins.hilt)
    id "kotlin-kapt"
}

android {
    signingConfigs {
        release {
            keyAlias 'hboxs'
            keyPassword 'android'
            storeFile file('../hboxs.jks')
            storePassword 'android'
        }
    }
    namespace 'com.quyunshuo.androidbaseframemvvm'
    compileSdk ProjectBuildConfig.compileSdkVersion

    defaultConfig {
        applicationId ProjectBuildConfig.applicationId
        minSdk ProjectBuildConfig.minSdkVersion
        targetSdk ProjectBuildConfig.targetSdkVersion
        versionCode ProjectBuildConfig.versionCode
        versionName ProjectBuildConfig.versionName
        flavorDimensions "default"
        testInstrumentationRunner DependencyConfig.AndroidX.AndroidJUnitRunner
        multiDexKeepProguard file("multidexKeep.pro")

        manifestPlaceholders = [
                GETUI_APP_ID    : "GKa6qa12heALjEXZlAn1U3",
                GETUI_APP_KEY   : "89WV8dfjRg6RlxEchgmnS6",
                GETUI_APP_SECRET: "fLvPjR8hni7VFMkgjh8lx2"
        ]
        ndk {
            // 设置支持的SO库架构
//            abiFilters 'armeabi', 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
            abiFilters 'armeabi-v7a', 'arm64-v8a'
        }



        packagingOptions {
            exclude 'META-INF/io.netty.versions.properties'
        }
    }
    configurations.all {
        resolutionStrategy {
            force 'commons-codec:commons-codec:1.15'
        }
    }
    signingConfigs {
        release {
            keyAlias 'sc'
            keyPassword '1234567890'
            storeFile file('../snowcone.jks')
            storePassword '1234567890'
        }
    }
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }
    buildTypes {
        // 对应 ALPHA 版本
        debug {
            buildConfigField "String", "VERSION_TYPE", "\"${ProjectBuildConfig.Version.ALPHA}\""
//            signingConfig signingConfigs.releaseConfig
            minifyEnabled false //为true，则对代码进行混淆和压缩
//            shrinkResources false //为true， 则对资源进行缩减
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }
        beta {
            buildConfigField "String", "VERSION_TYPE", "\"${ProjectBuildConfig.Version.BETA}\""
//            signingConfig signingConfigs.releaseConfig
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        release {
            buildConfigField "String", "VERSION_TYPE", "\"${ProjectBuildConfig.Version.RELEASE}\""
//            signingConfig signingConfigs.releaseConfig
            minifyEnabled false
//            shrinkResources true //为true， 则对资源进行缩减
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }

    }

    // 自定义打包apk的文件名
    android.applicationVariants.all { variant ->
        variant.outputs.all { output ->
            if (outputFileName != null && outputFileName.endsWith('.apk')) {
                outputFileName = "${ProjectBuildConfig.applicationId}" +
                        "_${ProjectBuildConfig.versionCode}" +
                        "_${ProjectBuildConfig.versionName}" +
                        "_${variant.buildType.name}" +
                        ".apk"
            }
        }
    }
    productFlavors {
        china {
            buildConfigField("boolean", "APP_TYPE", "true")
        }
        abroad {
            buildConfigField("boolean", "APP_TYPE", "false")
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = '17'
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])

    if (!ProjectBuildConfig.isAppMode) {
        implementation project(path: ':module_home')
        implementation project(path: ':module_backstage')
        implementation project(path: ':module_pay')
        implementation project(path: ':module_database')
        implementation project(path: ':serialport-api')
    } else {
        implementation project(path: ':lib_common')
    }
    implementation DependencyConfig.JetPack.HiltCore
    implementation project(':lib_base')

    kapt DependencyConfig.GitHub.AutoServiceAnnotations
    kapt DependencyConfig.JetPack.HiltApt
}