plugins {
    id "st-application-conventions"
    alias libs.plugins.firebase.crashlytics apply false
}

applyCrashlyticsIfRelease()

android {
    namespace "app.dapk.st"
    defaultConfig {
        applicationId "app.dapk.st"
    }
    buildTypes {
        release {
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
                    'proguard/app.pro',
                    "proguard/serializationx.pro",
                    "proguard/olm.pro"
        }
    }
}

dependencies {
    coreLibraryDesugaring libs.android.desugar

    implementation project(":features:home")
    implementation project(":features:directory")
    implementation project(":features:login")
    implementation project(":features:settings")
    implementation project(":features:notifications")
    implementation project(":features:messenger")
    implementation project(":features:profile")
    implementation project(":features:navigator")
    implementation project(":features:share-entry")

    implementation project(":domains:android:compose-core")
    implementation project(":domains:android:core")
    implementation project(":domains:android:tracking")
    implementation project(":domains:android:push")
    implementation project(":domains:android:work")
    implementation project(":domains:android:imageloader")
    implementation project(":domains:store")

    firebase(it, "messaging")

    implementation project(":core")

    implementation "chat-engine:chat-engine"
    implementation "chat-engine:matrix-chat-engine"
    implementation "chat-engine.matrix:store"

    implementation libs.ktor.android
    implementation libs.sqldelight.android
    implementation libs.matrix.olm

    implementation libs.kotlin.serialization
    debugImplementation libs.leakcanary
}

def applyCrashlyticsIfRelease() {
    if (isReleaseBuild && !isFoss()) {
        project.apply plugin: libs.plugins.firebase.crashlytics.get().pluginId
        project.afterEvaluate {
            project.tasks.withType(com.google.firebase.crashlytics.buildtools.gradle.tasks.UploadMappingFileTask).configureEach {
                it.googleServicesResourceRoot.set(project.file("src/release/res/"))
            }
        }
    }
}