apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

kapt {
    arguments {
        arg("AROUTER_MODULE_NAME", project.getName())
    }
}

android {
    compileSdkVersion 28
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.ydl.component"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        //统一维度
        flavorDimensions "versionCode"
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
                arguments = [AROUTER_MODULE_NAME: project.getName(), AROUTER_GENERATE_DOC: "enable"]
            }
        }

        multiDexEnabled true
        ndk {
            abiFilters "arm64-v8a"  // 指定要ndk需要兼容的架构(这样其他依赖包里mips,x86,armeabi,arm-v8之类的so会被过滤掉)
        }
    }

    //配置签名文件
    signingConfigs {
        ydl {
            storeFile file("keystore.jks")
            storePassword "123456"
            keyAlias "ydl"
            keyPassword "123456"
        }

        xlzx {
            storeFile file("keystore.jks")
            storePassword "123456"
            keyAlias "ydl"
            keyPassword "123456"
        }
    }

    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }


    buildTypes {

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

        debug {
            signingConfig signingConfigs.ydl
        }

//        debug {
//            versionNameSuffix "-debug"
//            signingConfig null
//        }
    }


    buildToolsVersion = '28.0.3'

    dexOptions {
        //使用增量模式构建
//        incremental true//最大堆内存
        javaMaxHeapSize "4g"//是否支持大工程模式
        jumboMode = true//预编译
        preDexLibraries = true//线程数
        threadCount = 8
        //禁止打了运行时注解的类全部打到主dex中
        keepRuntimeAnnotatedClasses = false
//        additionalParameters = ["--minimal-main-dex"]
    }

    //多维度
    //flavorDimensions "APP", "SERVER"

    productFlavors {
        ydl {
            applicationId rootProject.ext.ydl_app["applicationId"]
            versionName rootProject.ext.ydl_app["versionName"]
            versionCode rootProject.ext.ydl_app["versionCode"]

            //应用名
            resValue "string", "app_name", rootProject.ext.ydl_app["appName"]

            manifestPlaceholders = [
                    JPUSH_PKGNAME : applicationId,
                    JPUSH_APPKEY  : "e4b0d0bb7ef01053c93e25ba", //JPush上注册的包名对应的appkey.
                    JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.

                    XIAOMI_APPKEY : "MI-5241743243980",//小米平台注册的appkey
                    XIAOMI_APPID  : "MI-2882303761517432980",//小米平台注册的appid

                    HUAWEI_APPID  : "10444675",//华为平台注册的appid

                    OPPO_APPKEY   : "OP-afk71f35VogGw0w0wKsookksc", // OPPO平台注册的appkey
                    OPPO_APPID    : "OP-3245516", // OPPO平台注册的appid
                    OPPO_APPSECRET: "OP-691184F044acA7a6851F578451f67616",//OPPO平台注册的appsecret

                    MEIZU_APPKEY  : "MZ-00d268d7228748479036f202d45b4ef2",//魅族平台注册的appkey
                    MEIZU_APPID   : "MZ-120344",//魅族平台注册的appid
                    qqappid       : "1105070461",
                    APPLICATIONID : rootProject.ext.ydl_app["applicationId"]
            ]

            //签名文件
            signingConfig signingConfigs.ydl
        }


        xlzx {
            applicationId rootProject.ext.xlzx_app["applicationId"]
            versionName rootProject.ext.xlzx_app["versionName"]
            versionCode rootProject.ext.xlzx_app["versionCode"]

            //应用名
            resValue "string", "app_name", rootProject.ext.xlzx_app["appName"]

            manifestPlaceholders = [
                    JPUSH_PKGNAME : applicationId,
                    JPUSH_APPKEY  : "e4b0d0bb7ef01053c93e25ba", //JPush上注册的包名对应的appkey.
                    JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.

                    XIAOMI_APPKEY : "MI-5241743243980",//小米平台注册的appkey
                    XIAOMI_APPID  : "MI-2882303761517432980",//小米平台注册的appid

                    HUAWEI_APPID  : "10444675",//华为平台注册的appid

                    OPPO_APPKEY   : "OP-afk71f35VogGw0w0wKsookksc", // OPPO平台注册的appkey
                    OPPO_APPID    : "OP-3245516", // OPPO平台注册的appid
                    OPPO_APPSECRET: "OP-691184F044acA7a6851F578451f67616",//OPPO平台注册的appsecret

                    MEIZU_APPKEY  : "MZ-00d268d7228748479036f202d45b4ef2",//魅族平台注册的appkey
                    MEIZU_APPID   : "MZ-120344",//魅族平台注册的appid
                    qqappid       : "1105070461",
                    APPLICATIONID : rootProject.ext.xlzx_app["applicationId"]
            ]

            //签名文件
            signingConfig signingConfigs.xlzx
        }
    }

    packagingOptions {
        exclude 'META-INF/proguard/coroutines.pro'
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.2.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//    kapt rootProject.ext.dependencies["dagger2-compiler"]

    api rootProject.ext.dependencies["butterknife"]
    kapt rootProject.ext.dependencies["butterknife-compiler"]

    if (true) {
        //开发模式
        implementation fileTree(dir: 'aars', include: ['*.aar'])
        implementation project(':m-user')
        implementation modularPublication('com.ydl:m-user-api')
        implementation project(':m-confide')
        implementation modularPublication('com.ydl:m-confide-api')
        api project(':m-consultant')
        implementation modularPublication('com.ydl:m-consultant-api')
        api project(':m-tests')


        api project(':m-home')
        api project(':m-confide')


        implementation project(':ydl-flutter-base')

        api(project(':ydl-platform')) {
            transitive = true
        }
        implementation project(':ydl-webview')
        implementation project(':ydl-media')


        implementation project(':m-muse')
        implementation project(':m-im')
        implementation modularPublication('com.ydl:m-im-api')
        implementation project(':m-dynamic')
        implementation project(':m-course')
        //文章模块
        implementation project(':m-article')
        implementation project(':m-audioim')
        implementation modularPublication('com.ydl:m-audioim-api')

        implementation project(':m-fm')
        implementation modularPublication('com.ydl:m-fm-api')
    } else {

        //发布模式
        api 'com.ydl:m-user-module-ydl:0.0.6'
        api rootProject.ext.dependencies["ydl-webview"]
        api rootProject.ext.dependencies["ydl-m-user-api"]
        api rootProject.ext.dependencies["ydl-m-fm-api"]
        api rootProject.ext.dependencies["m-article"]
        api(rootProject.ext.dependencies["ydl-platform"]) {
            transitive = true
        }
    }


    implementation rootProject.ext.dependencies["retrofit-url-manager"]
    kapt 'com.alibaba:arouter-compiler:1.2.2'
}
