project.ext {
    sign = [
            keystore_path : "../signature/innovationapp.jks",
            keystore_pwd  : "123456",
            keystore_alias: "yinuo"
    ]

    compileOptions = [
            sourceCompatibility: JavaVersion.VERSION_1_8,
            targetCompatibility: JavaVersion.VERSION_1_8,
    ]

    versions = [
            compileSdkVersion      : 30,
            buildToolsVersion      : "30.0.3",
            minSdkVersion          : 23,
            targetSdkVersion       : 28,
            versionCode            : 1,
            versionName            : "1.0",
            jvmTarget              : "1.8",

            appcompat              : "1.2.0",
            material               : "1.2.1",
            okhttp                 : "4.9.1",
            retrofit               : "2.9.0",
            rxjava                 : "3.0.13",
            rxandroid              : "3.0.0",
            kotlin                 : "1.5.10",
            kotlin_android         : "1.5.0",
            converter_gson         : '2.9.0',
            retrofit_rxjava        : "2.9.0",
            room                   : "2.3.0",
            jxl                    : "2.6.12",
            navigation_fragment_ktx: "2.3.0",
            navigation_ui_ktx      : "2.3.0",
            glide                  : "4.12.0",
            photo_view             : "2.3.0",
            luban                  : "1.1.8",
            gson                   : "2.8.6",
            arouter                : "1.5.2",
            mmkv                   : "1.2.10",
            okhttp_logger          : "3.12.7",
            lifecycle_process      : "2.3.1",
    ]

    dependencies = [
            okhttp                 : "com.squareup.okhttp3:okhttp:${versions.okhttp}",
            retrofit               : "com.squareup.retrofit2:retrofit:${versions.retrofit}",
            rxjava                 : "io.reactivex.rxjava3:rxjava:${versions.rxjava}",
            rxandroid              : "io.reactivex.rxjava3:rxandroid:${versions.rxandroid}",
            okhttp_logger          : "com.squareup.okhttp3:logging-interceptor:${versions.okhttp_logger}",
            kotlin                 : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}",
            kotlin_android         : "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.kotlin_android}",
            converter_gson         : "com.squareup.retrofit2:converter-gson:${versions.converter_gson}",
            retrofit_rxjava        : "com.squareup.retrofit2:adapter-rxjava3:${versions.retrofit_rxjava}",
            room                   : "androidx.room:room-runtime:${versions.room}",
            room_compiler          : "androidx.room:room-compiler:${versions.room}",
            room_ktx               : "androidx.room:room-ktx:${versions.room}",
            room_rxjava            : "androidx.room:room-rxjava3:${versions.room}",
            jxl                    : "net.sourceforge.jexcelapi:jxl:${versions.jxl}",
            navigation_fragment_ktx: "androidx.navigation:navigation-fragment-ktx:${versions.navigation_fragment_ktx}",
            navigation_ui_ktx      : "androidx.navigation:navigation-ui-ktx:${versions.navigation_ui_ktx}",
            navigation_arg         : "androidx.navigation:navigation-safe-args-gradle-plugin:${versions.navigation_ui_ktx}",
            glide                  : "com.github.bumptech.glide:glide:${versions.glide}",
            gilde_integration      : "com.github.bumptech.glide:okhttp3-integration:${versions.glide}",
            annotationProcessor    : "com.github.bumptech.glide:compiler:${versions.glide}",
            photo_view             : "com.github.chrisbanes:PhotoView:${versions.photo_view}",
            luban                  : "top.zibin:Luban:${versions.luban}",
            gson                   : "com.google.code.gson:gson:${versions.gson}",
            arouter                : "com.alibaba:arouter-api:${versions.arouter}",
            arouter_compiler       : "com.alibaba:arouter-compiler:${versions.arouter}",
            mmkv                   : "com.tencent:mmkv-static:${versions.mmkv}",
            lifecycle_process      : "androidx.lifecycle:lifecycle-process:${versions.lifecycle_process}",
    ]

    /**
     * android project android {} default config
     */
    setAndroidConfig = {
        extension ->
            extension.compileSdkVersion versions.compileSdkVersion

            extension.defaultConfig {
                minSdkVersion versions.minSdkVersion
                targetSdkVersion versions.targetSdkVersion
                versionCode versions.versionCode
                versionName versions.vserionName

                testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
            }

            extension.compileOptions {
                targetCompatibility = compileOptions.targetCompatibility
                sourceCompatibility = compileOptions.sourceCompatibility
            }

            extension.kotlinOptions {
                jvmTarget = versions.jvmTarget
            }
    }

    /**
     * android project dependencies {} default config
     */
    setDependencies = {
        extension ->
            extension.implementation fileTree(include: ['*.jar'], dir: 'libs')
    }

    /**
     * android library config
     */
    setLibDefaultConfig = {
        extension ->
            extension.apply plugin: 'com.android.library'
            extension.apply plugin: 'kotlin-android'
            extension.apply plugin: 'kotlin-parcelize'
            extension.apply plugin: 'kotlin-kapt'
            extension.description "lib"

            setAndroidConfig extension.android
            setDependencies extension.dependencies
    }

    /**
     * android application config
     */
    setAppDefaultConfig = {
        extension ->
            extension.apply plugin: 'com.android.application'
            extension.apply plugin: 'kotlin-android'
            extension.apply plugin: 'kotlin-parcelize'
            extension.apply plugin: 'kotlin-kapt'
            extension.description "lib"

            setAndroidConfig extension.android
            setDependencies extension.dependencies
    }

    /**
     * android library common config
     */
    setArouterConfig = {
        extension ->
            extension.android.defaultConfig {
                javaCompileOptions {
                    annotationProcessorOptions {
                        arguments = [AROUTER_MODULE_NAME: project.getName()]
                    }
                }
            }

            // 添加ARouter依赖
            extension.dependencies.implementation(rootProject.ext.dependencies.arouter) {
                exclude group: 'com.android.support'
            }
            extension.dependencies.annotationProcessor rootProject.ext.dependencies.arouter_compiler
    }
}