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

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

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

android {
    compileSdkVersion rootProject.ext.android["compileSdkVersion"]
    buildToolsVersion rootProject.ext.android["buildToolsVersion"]

    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }

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

        multiDexEnabled true
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        flavorDimensions "versionCode"
        vectorDrawables.useSupportLibrary = true
    }

    lintOptions {
        abortOnError false
    }

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

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

    sourceSets {
        main {
            res.srcDirs = ['src/main/res']
        }
    }
}

dependencies {
    api fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.fragment:fragment-ktx:1.2.4'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    api "com.airbnb.android:lottie:3.4.0"

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

    implementation rootProject.ext.dependencies["ydl-user-router"]

    if (rootProject.ext.dev_mode){
        //开发时使用
        implementation modularPublication('com.ydl:m-consultant-api')
        implementation modularPublication('com.ydl:m-user-api')
        implementation modularPublication('com.ydl:m-tests-api')
        implementation modularPublication('com.ydl:m-home-api')
        implementation modularPublication('com.ydl:m-im-api')
        implementation project(':ydl-webview')
        implementation project(':ydl-media')
        implementation project(":ydl-platform")
    } else {
        //发布时使用

        compileOnly rootProject.ext.dependencies["ydl-m-consultant-api"]
        compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
        compileOnly rootProject.ext.dependencies["ydl-m-home-api"]
        compileOnly rootProject.ext.dependencies['ydl-m-tests-api']
        compileOnly rootProject.ext.dependencies["ydl-m-im-api"]
        api (rootProject.ext.dependencies["ydl-platform"]) {
            transitive = true
        }
        api rootProject.ext.dependencies["ydl-webview"]
        api rootProject.ext.dependencies["ydl-media"]
    }
}