apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.starter.easylauncher'
apply plugin: "com.github.ben-manes.versions"

android {
    kotlinOptions.useIR = true
    compileSdkVersion(Dependencies.compileSdk)
    defaultConfig {
        applicationId "xyz.hisname.fireflyiii"
        minSdkVersion(Dependencies.minSdk)
        targetSdkVersion(Dependencies.targetSdk)
        versionCode 113
        versionName "5.1.0"
        multiDexEnabled true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'

        vectorDrawables.useSupportLibrary = true
        def appConfigFile = file('config.properties')
        def hostName = ""
        if(appConfigFile.exists()){
            Properties appConfig = new Properties()
            appConfig.load(new FileInputStream(appConfigFile))
            if(appConfig['config.hostname'] != null){
                hostName = appConfig['config.hostname']
                manifestPlaceholders = [host: hostName.replaceAll('"', '')]
            }
        } else {
            throw new FileNotFoundException("$appConfigFile not found!")
        }
        buildConfigField("String", "HOSTNAME", hostName)
    }

    testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
    }

    buildTypes {
         release {
            postprocessing {
                removeUnusedCode true
                removeUnusedResources true
                obfuscate false
                optimizeCode true
                proguardFiles = ['proguard-rules.pro']
            }
        }
        debug {
            applicationIdSuffix '.debug'
            versionNameSuffix "-debug"
            minifyEnabled false
        }
        // Do not use `JavaVersion.VERSION_11`! Will cause issues on `release` builds due to Proguard
        // Needs more investigation before using 11.  See issue #192
        compileOptions {
            coreLibraryDesugaringEnabled true
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
    }

    buildFeatures {
        viewBinding true
    }


    bundle {
        // Never set this to true otherwise we will have to depend on proprietary Play Core library
        language {
            enableSplit = false
        }
    }

    configurations {all*.exclude group: 'com.android.support'}
    androidResources {
        ignoreAssetsPattern 'NOTICE.txt'
    }
    namespace 'xyz.hisname.fireflyiii'
}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')

    androidx()
    network()
    kotlin()
    glide()
    markdown()
    moshi()
    testing()

    implementation Dependencies.materialDrawer
    implementation Dependencies.materialDrawerIconics
    implementation Dependencies.iconics
    implementation Dependencies.googleMaterialIcons
    implementation Dependencies.fontAwesome

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

    implementation Dependencies.toasty
    implementation Dependencies.chart
    implementation Dependencies.aboutLib
    implementation Dependencies.nachos
    implementation Dependencies.acraMail
    implementation Dependencies.osmdroid
    implementation Dependencies.accordionView
    implementation Dependencies.fancyshowcaseview
    implementation Dependencies.notificationLib
    implementation Dependencies.calendarView
    implementation Dependencies.taskerPluginLib
    implementation 'com.jakewharton.timber:timber:5.0.1'

    // Project Lib
    implementation project(path: ":languagepack")

}