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

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

    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
    buildToolsVersion rootProject.ext.android["buildToolsVersion"]

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        if (project.ext.runAsApp) {
            applicationId 'com.gingersoft.gsa.cloud.login'
        }
        minSdkVersion rootProject.ext.android["minSdkVersion"]
        targetSdkVersion rootProject.ext.android["targetSdkVersion"]
        versionCode rootProject.ext.android["versionCode"]
        versionName rootProject.ext.android["versionName"]
        multiDexEnabled true
        //配置注解处理器
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
            }
        }
    }

    resourcePrefix "user_login"
    bundle {
        density {
            // Different APKs are generated for devices with different screen densities; true by default.
            enableSplit true
        }
        abi {
            // Different APKs are generated for devices with different CPU architectures; true by default.
            enableSplit true
        }
        language {
            // This is disabled so that the App Bundle does NOT split the APK for each language.
            // We're gonna use the same APK for all languages.
            enableSplit true
        }
    }
    buildTypes {
        debug {
            buildConfigField "boolean", "LOG_DEBUG", rootProject.ext.buildType["debugLogDebug"]
            buildConfigField "boolean", "USE_CANARY", rootProject.ext.buildType["debugUseCanary"]
            minifyEnabled false
            proguardFiles 'proguard.cfg'
            signingConfig signingConfigs.GSAndroidNew
        }
        release {
            buildConfigField "boolean", "LOG_DEBUG", rootProject.ext.buildType["releaseLogDebug"]
            buildConfigField "boolean", "USE_CANARY", rootProject.ext.buildType["releaseUseCanary"]
            minifyEnabled false
            zipAlignEnabled false
            proguardFiles 'proguard.cfg'
            signingConfig signingConfigs.GSAndroidNew
        }
    }

    lintOptions {
        abortOnError false
    }
    dataBinding {
        enabled = true
    }
    //修改生成的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 = "正式版_GSA-Cloud_${variant.mergedFlavor.versionName}_${formattedDate}.apk"
            } else if (variant.buildType.name == 'debug') {
                fileName = "测试版_GSA-Cloud_${variant.mergedFlavor.versionName}_${formattedDate}.apk"
            }
            outputFileName = fileName
        }
    }
    dexOptions {
//        incremental true
        javaMaxHeapSize "4g"
    }
}
//dokit 扩展
dokitExt {
    //通用设置
    comm {
        //地图经纬度开关
        gpsSwitch true
        //网络开关
        networkSwitch true
        //大图开关
        bigImgSwitch true
        //webView js 抓包
        webViewSwitch true
    }

    slowMethod {
        //调用栈模式配置
        stackMethod {
            //默认值为 5ms 小于该值的函数在调用栈中不显示
            thresholdTime 5
            //调用栈函数入口
            enterMethods = ["com.didichuxing.doraemondemo.MainDebugActivity.test1"]
            //黑名单 粒度最小到类 暂不支持到方法
            methodBlacklist = ["com.facebook.drawee.backends.pipeline.Fresco"]
        }
        //普通模式配置
        normalMethod {
            //默认值为 500ms 小于该值的函数在运行时不会在控制台中被打印
            thresholdTime 100
            //需要针对函数插装的包名
            packageNames = ["com.didichuxing.doraemondemo"]
            //不需要针对函数插装的包名和类名
            methodBlacklist = ["com.didichuxing.doraemondemo.dokit"]
        }
    }
}

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

    addComponent 'component-main'
    addComponent 'component-download'
    addComponent 'component-print'
    addComponent 'component-supply-chain'
    addComponent 'component-scan'

    implementation rootProject.ext.dependencies["viewpager2"]
    annotationProcessor rootProject.ext.dependencies["dagger2-compiler"]
    implementation rootProject.ext.dependencies["autosize"]
}
