apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

apply plugin: 'resTools' // 资源重命名插件

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

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

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"

        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        flavorDimensions "versionCode"

    }

    lintOptions {
        abortOnError false
    }

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

    //前缀的名字
    resourcePrefix "tests_"

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

}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    implementation 'com.google.code.gson:gson:2.8.2'

    implementation "com.alibaba:arouter-api:$arouter_api"
//    注意此处的依赖方式:kotlin中使用和java中使用方式有不同
    kapt "com.alibaba:arouter-compiler:$arouter_compiler"

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

        api rootProject.ext.dependencies["ydl-webview"]
        api(rootProject.ext.dependencies["ydl-platform"]) {
            transitive = true
        }

        implementation rootProject.ext.dependencies["ydl-flutter-base"]
    }
}