/*
 * Copyright (c) 2021 2bllw8
 * SPDX-License-Identifier: GPL-3.0-only
 */
plugins {
    id("com.android.application")
}

android {
    namespace = rootProject.ext.namespace
    compileSdk = rootProject.ext.targetSdkVersion

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

    buildFeatures {
        buildConfig = false
    }

    compileOptions {
        sourceCompatibility rootProject.ext.sourceCompatibilityVersion
        targetCompatibility rootProject.ext.targetCompatibilityVersion
    }

    dependenciesInfo {
        includeInApk = false
    }

    signingConfigs {
        if (rootProject.ext.keyStoreFile != null && rootProject.ext.keyStoreFile.exists()) {
            anemo {
                storeFile file(rootProject.ext.keyStoreFile)
                storePassword rootProject.ext.keyStorePassword
                keyAlias rootProject.ext.keyAlias
                keyPassword rootProject.ext.keyPassword
            }
        }
    }

    buildTypes {
        def useAnemoConfig = rootProject.ext.keyStoreFile != null
                && rootProject.ext.keyStoreFile.exists()

        release {
            minifyEnabled = true
            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"

            if (useAnemoConfig) {
                signingConfig = signingConfigs.named("anemo").get()
            }
        }
        debug {
            if (useAnemoConfig) {
                signingConfig = signingConfigs.named("anemo").get()
            }
        }
    }
}

dependencies {
    def androidxAnnotation = "androidx.annotation:annotation:1.3.0"
    def eitherLib = "io.github.2bllw8:either:3.4.0"

    implementation androidxAnnotation
    implementation eitherLib
}
