plugins {
    alias(libs.plugins.androidApplication)
    alias(libs.plugins.kotlinAndroid)
    alias(libs.plugins.compose.compiler)
    alias(libs.plugins.serialization)
}

android {
    namespace 'io.github.chinosk.gakumas.localify'
    compileSdk 34
    ndkVersion "26.3.11579264"

    defaultConfig {
        applicationId "io.github.chinosk.gakumas.localify"
        minSdk 29
        targetSdk 34
        versionCode 2
        versionName "v1.2"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
        externalNativeBuild {
            cmake {
                cppFlags ''
            }
        }
        ndk {
            abiFilters 'arm64-v8a'
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField "boolean", "ENABLE_LOG", "true"
            signingConfig signingConfigs.debug
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
    }
    buildFeatures {
        buildConfig true
        compose true
        prefab true
    }
    externalNativeBuild {
        cmake {
            path file('src/main/cpp/CMakeLists.txt')
            version '3.22.1'
        }
    }

    packaging {
        jniLibs {
            pickFirsts += "**/libxdl.so"
            pickFirsts += "**/libshadowhook.so"
        }
        resources {
            excludes += "**/META-INF/{AL2.0,LGPL2.1}"
            excludes += "kotlin/**"
            excludes += "**.bin"
        }
    }

    applicationVariants.configureEach { variant ->
        variant.mergeAssetsProvider.configure { mergeAssetsTask ->
            mergeAssetsTask.doLast {
                delete(fileTree(dir: mergeAssetsTask.outputDir, includes: ['gakumas-local/scripts/**',
                                                                           'gakumas-local/README.md']))
            }
        }
    }
}

dependencies {
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.lifecycle.runtime.ktx)
    implementation(libs.androidx.material3)
    implementation(libs.material)

    implementation(libs.androidx.activity.compose)
    implementation(libs.androidx.appcompat)
    implementation(libs.androidx.navigation.compose)

    def composeBom = platform(libs.androidx.compose.bom)
    implementation(composeBom)
    androidTestImplementation(composeBom)
    implementation(libs.androidx.runtime)
    implementation(libs.androidx.material)
    implementation(libs.androidx.foundation)
    implementation(libs.androidx.foundation.layout)
    implementation(libs.androidx.animation)
    implementation(libs.androidx.ui.tooling.preview)
    androidTestImplementation(libs.androidx.ui.test.junit4)
    debugImplementation(libs.androidx.ui.tooling)
    debugImplementation(libs.androidx.ui.test.manifest)
    implementation(libs.accompanist.pager)
    implementation(libs.accompanist.pager.indicators)
    implementation(libs.androidx.lifecycle.viewmodel.compose)

    implementation(libs.coil.compose)
    implementation(libs.coil.svg)

    implementation(platform(libs.okhttp.bom))
    implementation(libs.okhttp)
    implementation(libs.logging.interceptor)

    implementation(libs.xdl)
    implementation(libs.shadowhook)
    compileOnly(libs.xposed.api)
    implementation(libs.kotlinx.serialization.json)
}