apply plugin: 'com.android.application'


//加载core.properties
Properties properties = new Properties()
InputStream inputStream = project.getParent().file('core.properties').newDataInputStream() ;
properties.load( inputStream )

def version = '1.0.0'
def version_code = 2022110201
android {
    compileSdkVersion rootProject.ext.compile_sdk_version

    defaultConfig {
        applicationId properties.getProperty("CORE_PACKAGENAME_64")
        minSdkVersion rootProject.ext.min_sdk_version
        targetSdkVersion rootProject.ext.target_sdk_version
        versionCode version_code
        versionName version
        externalNativeBuild {
            ndkBuild {
                abiFilters "arm64-v8a"
            }
        }
        manifestPlaceholders = [
                CORE_PACKAGENAME : properties.getProperty("CORE_PACKAGENAME"),
                CORE_PACKAGENAME_64: properties.getProperty("CORE_PACKAGENAME_64"),
                VA_VERSION        : '' + version_code,
        ]

        ndk {
            abiFilters "arm64-v8a"
        }
    }

    buildTypes {
        debug {
            debuggable true
        }
        release {
            debuggable false
        }
    }

    lintOptions {
        abortOnError false
    }
    sourceSets {
        main {
            if (Boolean.parseBoolean(IS_EVALUATION)) { // 是否是测评版本
                manifest.srcFile 'src/main/evaluation/AndroidManifest.xml'
            } else {
                manifest.srcFile 'src/main/AndroidManifest.xml'
            }
            jniLibs.srcDirs = ['libs']
        }
    }
    signingConfigs {
        String keyAliasValue = keyAlias
        String keyPasswordValue = keyPassword
        File keystoreFile = null
        String keystorePasswordValue = keystorePassword

        if (keyPasswordValue.length() == 0) {
            keyPasswordValue = System.getenv("keystore_password") ?: "wrong_password"
            println("get keyPassword from env.")
        } else {
            println("get keyPassword from properties.")
        }

        if (keystorePasswordValue.length() == 0) {
            keystorePasswordValue = keyPasswordValue
            println("keystorePasswordValue is empty, use keyPasswordValue")
        }

        if (keystorePath.length() == 0) {
            String keystorePathFromEnv = System.getenv("keystore_file") ?: " wrong_keystore"
            keystoreFile = file(keystorePathFromEnv)
            println("get keystorePath from env: " + keystoreFile)
        } else {
            println("get keystorePath from properties: " + keystorePath)
            keystoreFile = new File(getRootDir(), keystorePath)
        }

        release_config {
            keyAlias keyAliasValue
            keyPassword keyPasswordValue
            storeFile keystoreFile
            storePassword keystorePasswordValue
            v1SigningEnabled true
            v2SigningEnabled false
        }
    }
    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            zipAlignEnabled false
            signingConfig signingConfigs.release_config
            if (isWindows()) {
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro',
                        '..\\..\\proguards\\proguard_base.pro', '..\\..\\proguards\\proguard_third.pro',
                        '..\\..\\proguards\\proguard_lib.pro', '..\\..\\proguards\\proguard_lib_hook.pro'
            } else {
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro',
                        '../../proguards/proguard_base.pro', '../../proguards/proguard_third.pro',
                        '../../proguards/proguard_lib.pro', '../../proguards/proguard_lib_hook.pro'
            }
        }

        release {
            debuggable false
            minifyEnabled true
            zipAlignEnabled true
            if (isWindows()) {
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro',
                        '..\\..\\proguards\\proguard_base.pro', '..\\..\\proguards\\proguard_third.pro',
                        '..\\..\\proguards\\proguard_lib.pro', '..\\..\\proguards\\proguard_lib_hook.pro'
            } else {
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro',
                        '../../proguards/proguard_base.pro', '../../proguards/proguard_third.pro',
                        '../../proguards/proguard_lib.pro', '../../proguards/proguard_lib_hook.pro'
            }
            signingConfig signingConfigs.release_config
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "me.weishu:free_reflection:3.0.1"

}
