apply plugin: 'com.android.application'

static def getTime() {
    return new Date().format("yyyyMMdd_HHmm")
}

android {
    compileSdkVersion rootProject.ext.android.compileSdkVersion

    defaultConfig {
        minSdkVersion rootProject.ext.android.minSdkVersion
        targetSdkVersion rootProject.ext.android.targetSdkVersion
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    // 差异化打包配置
    flavorDimensions "mode"

    productFlavors {
        simple { // 简易版
            applicationId "com.fantasy.blogdemo"
            resValue "string", "app_name", "BlogDemo"
            buildConfigField "String", "SERVER_URL", "\"https://fantasy.com\""
        }
        profession { // 专业版
            applicationId "com.fantasy.blogdemo.pro"
            resValue "string", "app_name", "BlogDemoPro"
            buildConfigField "String", "SERVER_URL", "\"https://fantasy.pro.com\""
        }
    }

    // 自定义安装包的名称，这里使用了 productFlavors 的名称，这样简易版和专业版的安装包也就可以区分出来了
    applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "BLOG_V${variant.versionName}_${variant.versionCode}_${getTime()}" +
                    "_${variant.productFlavors[0].name}.apk"
        }
    }
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    // 权限申请，https://github.com/soulqw/SoulPermission
    implementation 'com.qw:soulpermission:1.1.7'

    implementation project(':lib_anti_emulator')

    /******************** 下面是 profession 专业版 单独需要的依赖 ********************/
    professionImplementation 'com.qmuiteam:qmui:1.2.0'
}
