/*
 *  ---license-start
 *  eu-digital-green-certificates / dgca-verifier-app-android
 *  ---
 *  Copyright (C) 2021 T-Systems International GmbH and all other contributors
 *  ---
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  ---license-end
 *
 *  Created by mykhailo.nester on 27/05/2021, 23:14
 */

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.30'
    id 'androidx.navigation.safeargs.kotlin'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
    id 'com.google.android.gms.oss-licenses-plugin'
    id 'kotlin-parcelize'
}

def debugKeystorePropertiesFile = rootProject.file("debug.keystore.properties")
def debugKeystoreProperties = new Properties()
debugKeystoreProperties.load(new FileInputStream(debugKeystorePropertiesFile))

android {
    compileSdkVersion Config.compileSdk

    defaultConfig {
        applicationId "dgca.verifier.app.android"
        minSdkVersion Config.minSdk
        targetSdkVersion Config.targetSdk
        versionCode Config.versionCode
        versionName Config.versionName

        testInstrumentationRunner Config.androidTestInstrumentation
        signingConfig signingConfigs.debug
    }

    signingConfigs {
        debug {
            keyAlias debugKeystoreProperties['keyAlias']
            keyPassword debugKeystoreProperties['keyPassword']
            storeFile file(debugKeystoreProperties['storeFile'])
            storePassword debugKeystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug
        }
    }

    flavorDimensions "version", "revocationDataSliceType"

    productFlavors {
        tst {
            dimension "version"
            versionNameSuffix "-tst"
        }

        acc {
            dimension "version"
            versionNameSuffix "-acc"
        }

        bloom {
            dimension "revocationDataSliceType"
            versionNameSuffix "-bloom"
        }

        hash {
            dimension "revocationDataSliceType"
            versionNameSuffix "-hash"
        }
    }

    compileOptions {
        sourceCompatibility Config.javaVersion
        targetCompatibility Config.javaVersion
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }

    buildFeatures {
        viewBinding true
    }

    packagingOptions {
        pickFirst 'META-INF/ASL-2.0.txt'
        pickFirst 'draftv4/schema'
        pickFirst 'draftv3/schema'
        pickFirst 'META-INF/LGPL-3.0.txt'
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def lintTask = tasks["lint${variant.name.capitalize()}"]
            output.assemble.dependsOn lintTask
        }
    }
}

dependencies {
    implementation project(":branches:base")
    implementation project(":branches:dcc")
    implementation project(':branches:dcc:revocation')
    implementation project(":branches:icao")
    implementation project(":branches:divoc")
    implementation project(":branches:vc")
    implementation project(":branches:shc")
    implementation project(":decoder")
    implementation project(":engine")

    implementation Deps.kotlin_stdlib
    implementation Deps.androidx_core
    implementation Deps.kotlinx_coroutines
    implementation Deps.androidx_appcompat
    implementation Deps.androidx_fragment_ktx
    implementation Deps.androidx_material
    implementation Deps.androidx_constraint
    implementation Deps.androidx_navigation_fragment
    implementation Deps.androidx_navigation_ui
    implementation Deps.androidx_worker_ktx

    implementation Deps.retrofit2
    implementation Deps.log_interceptor
    implementation Deps.gson_converter
    implementation Deps.jackson_kotlin

    implementation Deps.zxing
    implementation Deps.hilt
    kapt Deps.hilt_compiler
    implementation Deps.hilt_work

    implementation Deps.timber

    testImplementation Deps.test_junit
    testImplementation Deps.mockito_core
    testImplementation Deps.mockito_kotlin
    testImplementation Deps.mockito_inline
    androidTestImplementation Deps.test_ext
}