/*
 * SPDX-FileCopyrightText: 2020 The Calyx Institute
 * SPDX-License-Identifier: Apache-2.0
 */

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'org.calyxos.backup.contacts'
    compileSdk rootProject.ext.compileSdk

    defaultConfig {
        applicationId "org.calyxos.backup.contacts"
        minSdk rootProject.ext.minSdk
        targetSdk rootProject.ext.targetSdk

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments disableAnalytics: 'true'
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

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

    packagingOptions {
        exclude("META-INF/LICENSE.md")
        exclude("META-INF/LICENSE-notice.md")
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    // optional signingConfigs
    // On userdebug builds, you can use the testkey here to update the system app
    def keystorePropertiesFile = project.file("keystore.properties")
    if (keystorePropertiesFile.exists()) {
        def keystoreProperties = new Properties()
        keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

        signingConfigs {
            release {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
            }
        }
        buildTypes.release.signingConfig = signingConfigs.release
        buildTypes.debug.signingConfig = signingConfigs.release
    }
}

def aospDeps = fileTree(include: [
        // out/target/common/obj/JAVA_LIBRARIES/com.android.vcard_intermediates/classes.jar
        'com.android.vcard.jar'
], dir: 'libs')

dependencies {
    implementation aospDeps

    testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    testImplementation "junit:junit:$junit4_version"
    testImplementation "io.mockk:mockk:$mockk_version"

    androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
    androidTestImplementation "io.mockk:mockk-android:$mockk_version"
}
