plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'com.sensorsdata.analytics.android'
    id 'com.google.devtools.ksp'
}

android {
    compileSdk rootProject.ext.compileSdkVersion

    defaultConfig {
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

    flavorDimensions("env")

    productFlavors {
        // internal， 内部测试包使用的 flavor，接口包含包括测试和正式环境
        internal {
            dimension "env"

            manifestPlaceholders.put("SENSORS_SCHEME", "sad821cc0b")

            buildConfigField "String", "DEV_SA_SERVER_URL", "\"${DEV_SA_SERVER_URL}\""
            buildConfigField "String", "SA_SERVER_URL", "\"${SA_SERVER_URL}\""
        }

        // publish， 发布时候使用的 flavor，接口仅包含正式环境
        publish {
            dimension "env"

            manifestPlaceholders.put("SENSORS_SCHEME" , "sa9d121451")

            buildConfigField "String", "DEV_SA_SERVER_URL", "\"${SA_SERVER_URL}\""
            buildConfigField "String", "SA_SERVER_URL", "\"${SA_SERVER_URL}\""
        }

        tea {
            dimension "env"

            manifestPlaceholders.put("SENSORS_SCHEME" , "sa9d121451")

            buildConfigField "String", "DEV_SA_SERVER_URL", "\"${SA_SERVER_URL}\""
            buildConfigField "String", "SA_SERVER_URL", "\"${SA_SERVER_URL}\""
        }

        kuaishou {
            dimension "env"

            manifestPlaceholders.put("SENSORS_SCHEME" , "sa9d121451")

            buildConfigField "String", "DEV_SA_SERVER_URL", "\"${SA_SERVER_URL}\""
            buildConfigField "String", "SA_SERVER_URL", "\"${SA_SERVER_URL}\""
        }

        gdt {
            dimension "env"

            manifestPlaceholders.put("SENSORS_SCHEME" , "sa9d121451")

            buildConfigField "String", "DEV_SA_SERVER_URL", "\"${SA_SERVER_URL}\""
            buildConfigField "String", "SA_SERVER_URL", "\"${SA_SERVER_URL}\""
        }

        sm {
            dimension "env"

            manifestPlaceholders.put("SENSORS_SCHEME" , "sa9d121451")

            buildConfigField "String", "DEV_SA_SERVER_URL", "\"${SA_SERVER_URL}\""
            buildConfigField "String", "SA_SERVER_URL", "\"${SA_SERVER_URL}\""
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    sensorsAnalytics {
        sdk {
            disableIMEI = true
            disableCarrier = true
            disableMacAddress = true
        }
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {
    ksp "cn.therouter:apt:${routerVersion}"
    kapt "com.google.auto.service:auto-service:${autoServiceVersion}"

    implementation "com.sensorsdata.analytics.android:SensorsAnalyticsSDK:$sensorsDataVersion"
    implementation(project(path: ":module_common")) {
        exclude group: 'androidx.swiperefreshlayout'
    }
}