apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'resTools' // 资源重命名插件

// 配置资源重命名插件
resConfig {
    new_prefix = 'consultant_'  // 资源前缀
    old_prefix = ''         // 老前缀,可为''空字符串
}

kapt {
    arguments {
        arg("AROUTER_MODULE_NAME", "consultant")
    }
}
android {
    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
    buildToolsVersion rootProject.ext.android["buildToolsVersion"]

    defaultConfig {
        minSdkVersion rootProject.ext.android["minSdkVersion"]
        targetSdkVersion rootProject.ext.android["targetSdkVersion"]
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [AROUTER_MODULE_NAME: "consultant"]
            }
        }

        flavorDimensions "versionCode"
    }

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

    //前缀的名字
    resourcePrefix "consultant_"

    //Flavor 信息
    publishNonDefault true
    productFlavors {
        ydl {}
        xlzx {}
    }

    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    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'
    kapt 'com.alibaba:arouter-compiler:1.2.2'

    api rootProject.ext.dependencies["ydl-user-router"]
    if (rootProject.ext.dev_mode){
        //开发时使用
        implementation modularPublication('com.ydl:m-user-api')
        implementation modularPublication('com.ydl:m-im-api')
        api project(":ydl-webview")
        api project(":ydl-platform")
    } else {
        //发布时使用
        compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
        compileOnly rootProject.ext.dependencies["ydl-m-im-api"]
        api rootProject.ext.dependencies["ydl-webview"]
        api(rootProject.ext.dependencies["ydl-platform"]) {
            transitive = true
        }
    }
}