// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: "config.gradle"
buildscript {
    ext.kotlin_version = "1.5.21"
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
        classpath 'com.didichuxing.doraemonkit:dokitx-plugin:3.3.5'
    }
}

allprojects {
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

//子工程模块通用配置信息
subprojects { subproject ->
    if (subproject.getName().startsWith("biz_")) {

        apply from: "../common_module_config.gradle"
        apply from: "../arouter.gradle"

        android {
            //自定义自模块资源命名前缀，防止资源重复
            resourcePrefix subproject.getName().substring(subproject.getName().indexOf("_") + 1) + "_"
        }

        dependencies {
            implementation fileTree(dir: "libs", include: ["*.jar"])
            testImplementation rootProject.ext.androidx["junit"]
            androidTestImplementation rootProject.ext.androidx["androidx.test.espresso:espresso-core"]

            if (subproject.getName() != "biz_provider") {
                api project(path: ':biz_provider')

                //组件化使用hilt时，目前需要在每一个module中都以下配置
                implementation rootProject.ext.dependencies["hilt-android"]
                kapt rootProject.ext.dependencies["hilt-android-compiler"]
                kapt rootProject.ext.androidx["hilt-compiler"]
            }else{
                api project(path: ':lib_common')
            }
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}