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

android {
    // 在 DEFAULT_PLUGIN_URL 中提取插件版本号
    def defaultPluginUrl = "https://app-static.796697.com/va/plugin/2025/05/15/2.0.0_64_1747292406020.zip"
    def versionText = defaultPluginUrl.substring(defaultPluginUrl.lastIndexOf("/") + 1)
    def pluginVersionPattern = ~/^\d+.\d+.\d+/
    def matcher = versionText =~ pluginVersionPattern
    String va_plugin_version = null
    if (matcher) {
        va_plugin_version = matcher[0]
    }
    if(va_plugin_version == null) {
        throw IllegalStateException("url没有包含插件版本号，请检查url是否合法")
    }

    compileSdkVersion rootProject.ext.compileSdkVersion

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


        buildConfigField "String", "DEFAULT_PLUGIN_URL", "\"$defaultPluginUrl\""

    }

    buildFeatures {
        viewBinding true
        dataBinding true
    }

    buildTypes {
        release {
            consumerProguardFiles 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    flavorDimensions "env"
    productFlavors {
        internal {
            dimension "env"
            manifestPlaceholders.put("VA_PLUGIN_VERSION", va_plugin_version)
        }
        publish {
            dimension "env"
            manifestPlaceholders.put("VA_PLUGIN_VERSION", va_plugin_version)
        }
        tea {
            dimension "env"
            manifestPlaceholders.put("VA_PLUGIN_VERSION", va_plugin_version)
        }
        kuaishou {
            dimension "env"
            manifestPlaceholders.put("VA_PLUGIN_VERSION", va_plugin_version)
        }
        gdt {
            dimension "env"
            manifestPlaceholders.put("VA_PLUGIN_VERSION", va_plugin_version)
        }
        sm {
            dimension "env"
            manifestPlaceholders.put("VA_PLUGIN_VERSION", va_plugin_version)
        }

    }

}

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

    implementation(project(path: ":module_common")) {
        exclude group: 'androidx.swiperefreshlayout'
    }

    implementation(project(":module_va_api"))
    implementation(project(":va-archive-common"))
    implementation(project(":va-common"))
    implementation(project(":va-lib"))
    implementation(project(':va-main')) {
        exclude group: 'androidx.swiperefreshlayout'
    }
    implementation(project(":va-core"))
    implementation(project(":va-library-commons"))
    implementation(project(":va-archive"))
    implementation(project(":va-plugin-host-lib"))
    implementation(project(":va-plugin-host"))
}