import java.text.DateFormat
import java.text.SimpleDateFormat

plugins {
    alias libs.plugins.android.application
    alias libs.plugins.kotlin.android
    alias libs.plugins.ksp
    alias libs.plugins.appmetrica
}

static def getDateTime() {
    DateFormat df = new SimpleDateFormat("dd MMMMM yyyy")
    return df.format(new Date()) + " г."
}

android {
    namespace "ru.radiationx.anilibria"

    compileSdk app_compile_sdk_version

    defaultConfig {
        applicationId "ru.radiationx.anilibria.app"
        minSdk app_min_sdk_version
        targetSdk app_target_sdk_version
        versionCode mobile_version_code
        versionName mobile_version_name
        buildConfigField "String", 'BUILD_DATE', '"' + getDateTime() + '"'
        vectorDrawables.useSupportLibrary = true
        resourceConfigurations += ['ru']
    }

    buildFeatures {
        viewBinding true
        buildConfig true
    }

    buildTypes {
        debug {
            minifyEnabled false
            shrinkResources false
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    flavorDimensions = ["type"]
    productFlavors {
        app {
            dimension "type"
            buildConfigField "boolean", 'HAS_ADS', 'true'
        }

        store {
            dimension "type"
            applicationId "tv.anilibria.store"
            buildConfigField "boolean", 'HAS_ADS', 'false'
        }
    }

    applicationVariants.configureEach { variant ->
        variant.outputs.configureEach { output ->
            def appName = "AniLibria"
            def versionName = variant.versionName
            outputFileName = "${appName}_v${versionName}.apk"
        }
    }
}

kotlin {
    jvmToolchain(jvm_toolchain_version)
}

appmetrica {
    Properties properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())
    String propApiKey = properties.get("appmetrica_post_api_key", "")
    setPostApiKey(propApiKey)
}

dependencies {
    implementation libs.kotlin.stdlib
    implementation libs.androidx.constraintlayout

    implementation project(":data")
    implementation project(":shared-android-ktx")
    implementation project(":shared-app")
    implementation project(":quill-di")
    implementation project(":media-mobile")
    implementation project(":taiwa")
    implementation project(":envoy")

    implementation libs.androidx.activity
    implementation libs.androidx.appcompat
    implementation libs.google.material
    implementation libs.androidx.cardview
    implementation libs.androidx.swiperefreshlayout
    implementation libs.androidx.preference

    implementation libs.kotlin.coroutines.core

    implementation libs.cicerone

    implementation project(":searchbar")

    implementation libs.google.flexbox

    implementation libs.media3.exoplayer
    implementation libs.media3.exoplayer.hls
    implementation libs.media3.session

    implementation libs.minitemplator

    implementation libs.adapterdelegates

    implementation libs.mintpermissions
    implementation libs.mintpermissions.flows

    implementation libs.materialprogressbar

    compileOnly libs.toothpick
    ksp libs.toothpick.compiler

    implementation libs.androidnetworktools


    implementation libs.firebase.messaging
    implementation libs.firebase.core

    implementation libs.viewbindingpropertydelegate

    implementation libs.yandex.mobileads
}

apply plugin: "com.google.gms.google-services"