import org.checkerframework.checker.units.qual.A

ext.mainApp = true  //设置为true，表示此module为主app module，一直以application方式编译
apply from: rootProject.file('cc-settings.gradle')

//获取时间戳
def getDate() {
    def date = new Date()
    def formattedDate = date.format('yyyyMMddHH')
    return formattedDate
}

android {
    signingConfigs {
        GSAndroidNew {
            keyAlias 'keycypos'
            keyPassword 'qingkeke'
            storeFile file('cyposandroid.keyset')
            storePassword 'qingkeke'
        }
    }

    compileSdkVersion rootProject.ext.android["compileSdkVersion"]

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
    // 避免 lint 检测出错时停止构建
    lintOptions {
        abortOnError false
    }
    defaultConfig {
        applicationId "com.gingersoft.cloud.gsa"
        minSdkVersion rootProject.ext.android["minSdkVersion"]
        targetSdkVersion rootProject.ext.android["targetSdkVersion"]
        versionCode rootProject.ext.android["versionCode"]
        versionName rootProject.ext.android["versionName"]
        multiDexEnabled true
    }

    buildTypes {
        release {
            postprocessing {
                removeUnusedCode false
                removeUnusedResources false
                obfuscate false
                optimizeCode false
                proguardFiles 'proguard.cfg'
                signingConfig signingConfigs.GSAndroidNew
            }
        }
    }

    //修改生成的apk名字
    applicationVariants.all { variant ->
        variant.outputs.all {
            def fileName
            def date = new Date()
            def formattedDate = date.format('yyyy-MM-dd')
            if (variant.buildType.name == 'release') {
                fileName = "${formattedDate}_GsAndroid_${variant.mergedFlavor.versionName}_正式版_.apk"
            } else if (variant.buildType.name == 'Test') {
                fileName = "${formattedDate}__GsAndroid_${variant.mergedFlavor.versionName}_测试版_.apk"
            } else if (variant.buildType.name == 'debug') {
                fileName = "${formattedDate}__GsAndroid_${variant.mergedFlavor.versionName}_debug_.apk"
            }
            outputFileName = fileName
        }
    }
}

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

//    addComponent 'component_login'
//    addComponent 'component_register'
    implementation project(':public-base')
//    implementation project(':arms')

    implementation rootProject.ext.dependencies["arms"]
    // test
    testImplementation rootProject.ext.dependencies["junit"]
    debugImplementation rootProject.ext.dependencies["canary-debug"]
    releaseImplementation rootProject.ext.dependencies["canary-release"]
    testImplementation rootProject.ext.dependencies["canary-release"]
    implementation 'org.jetbrains:annotations:15.0'

}
