apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    // 将版本相关的属性剥离到属性文件中
    def Properties versionProps = new Properties()
    def versionPropsFile = file('version.properties')
    if (versionPropsFile.exists()) {
        versionProps.load(new FileInputStream(versionPropsFile))
    }
    def PACKAGE_NAME = versionProps['PACKAGE_NAME']
    def VERSION_CODE = versionProps['VERSION_CODE']
    def VERSION_NAME = versionProps['VERSION_NAME']
    def code = (VERSION_CODE ?: "0").toInteger()
    defaultConfig {
        applicationId PACKAGE_NAME
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode code
        versionName VERSION_NAME
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        flavorDimensions "1"
    }
    signingConfigs {
        debug {
            storeFile file(DEBUG_STORE_FILE)
            storePassword DEBUG_STORE_PASSWORD
            keyPassword DEBUG_KEY_PASSWORD
            keyAlias DEBUG_KEY_ALIAS
            v2SigningEnabled true
        }
        release {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyPassword RELEASE_KEY_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            v2SigningEnabled true
        }
    }
    buildTypes {
        //签名配置
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            //是否zip对齐
//            zipAlignEnabled true
            // 移除无用的resource文件
//            shrinkResources true

            minifyEnabled false

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            //签名配置
            signingConfig signingConfigs.release
        }
    }


    productFlavors {
        guanwang {}
        toutiao {}
        toutiao_h5 {}
        oppo{}
        xiaomi{}
        huawei{}
        meizu
        _360{}
        yyb{}
        hykb{}
        vivo{}
        zhihu{}
        bilibili{}
        baidu{}
        baidu{}
        bilibili{}
        baichuan{}
        kuaishou{}
        weibo{}
        zhihu{}
        tuia{}
        source1{}
        mbt{}
        baichuan{}
        huafei_h5{}
        sh{}
    }

    productFlavors.all {
        flavor ->
            flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    applicationVariants.all { variant ->
        //这个修改输出的APK路径

        if (variant.buildType.name != "debug") {//防止AS无法安装debug包(apk)
            variant.getPackageApplication().outputDirectory = new File(APK_PATH + versionProps['PACKAGE_NAME'] + "/" + variant.versionName + "/")
        }

        variant.outputs.all {
            //这个修改输出APK的文件名
            apkData.outputFileName = versionProps['PACKAGE_NAME'] +"_"+
                    variant.flavorName + "-" +
                    variant.versionName +
                    ".apk"
        }
    }
}
repositories {
    flatDir {
        dirs 'libs', '../cms/libs'
    }

}

dependencies {
    implementation project(':moduleMain')

    implementation "androidx.core:core-ktx:1.6.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.2.0'

}
