if (isRelease.toBoolean()) {
    apply plugin: 'com.android.library'
} else {
    apply plugin: 'com.android.application'
}
apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.devtools.ksp'

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        vectorDrawables.useSupportLibrary = true

        if (!isRelease.toBoolean()) {
            applicationId "com.gh.message"
            multiDexEnabled true

            buildConfigField "String", "API_HOST", "\"${API_HOST}\""
            buildConfigField "String", "NEW_API_HOST", "\"${NEW_API_HOST}\""
        }

        minSdk rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    sourceSets {
        main {
            if (isRelease.toBoolean()) {
                manifest.srcFile 'src/main/AndroidManifest.xml'
                java {
                    exclude 'manifest/**'
                }
            } else {
                java {
                    srcDirs = ['src/main/java', "src/message/java"]
                }
                manifest.srcFile 'src/main/manifest/AndroidManifest.xml'
            }
        }
    }

    buildFeatures {
        viewBinding true
    }

    ksp {
        arg("ROUTER_MODULE_NAME", project.name)
    }

    buildTypes {
        debug {
            if (!isRelease.toBoolean()) {
                buildConfigField "String", "DEV_API_HOST", "\"${DEV_API_HOST}\""
                buildConfigField "String", "NEW_DEV_API_HOST", "\"${NEW_DEV_API_HOST}\""
            }
        }

        release {
            consumerProguardFiles 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
    ksp "cn.therouter:apt:${routerVersion}"
    kapt "com.google.auto.service:auto-service:${autoServiceVersion}"

    if (!isRelease.toBoolean()) {
        implementation "androidx.multidex:multidex:${multiDex}"
    }
    implementation(project(path: ":module_common")) {
        exclude group: 'androidx.swiperefreshlayout'
    }
    implementation(project(path: ":module_login")) {
        exclude group: 'androidx.swiperefreshlayout'
    }
    implementation(project(':module_core_feature')) {
        exclude group: 'androidx.swiperefreshlayout'
    }
}