/*
 * // Copyright (c) Microsoft Corporation.
 * // All rights reserved.
 * //
 * // This code is licensed under the MIT License.
 * //
 * // Permission is hereby granted, free of charge, to any person obtaining a copy
 * // of this software and associated documentation files(the "Software"), to deal
 * // in the Software without restriction, including without limitation the rights
 * // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
 * // copies of the Software, and to permit persons to whom the Software is
 * // furnished to do so, subject to the following conditions :
 * //
 * // The above copyright notice and this permission notice shall be included in
 * // all copies or substantial portions of the Software.
 * //
 * // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * // THE SOFTWARE.
 */

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

def msalVersion = "5.10.0"

if (project.hasProperty("distMsalVersion")) {
    msalVersion = distMsalVersion
}

def otelAriaToken = ""

if(project.hasProperty('otelAriaToken')) {
    otelAriaToken = project.otelAriaToken;
}

android {
    namespace "com.microsoft.identity.client.testapp"
// Bumping up to Java Version 8 due to the addition of YubiKit SDK,
// which uses Version 8. Host apps that use libraries dependent on version 8
// must also integrate version 8.
    compileOptions {
        // Sets Java compatibility to Java 8
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        multiDexEnabled true
        applicationId "com.msft.identity.client.sample"
        minSdkVersion 24
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0"
        buildConfigField("String", "otelAriaToken", "\"${otelAriaToken}\"" )
    }
    signingConfigs {
        debug {
            storeFile file("./debug.keystore")
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }

        release {
            storeFile file("./debug.keystore")
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildFeatures {
        viewBinding true
        buildConfig true
    }
    lintOptions {
        abortOnError false
    }
    flavorDimensions "main"
    productFlavors {
        local {
            applicationIdSuffix ".local"
            versionNameSuffix "-local"
            resValue("string", "application_name", "msal-local")
        }
        dist {
            // Keep .local because the redirect url we registered on the portal contains .local, not .dist
            applicationIdSuffix ".local"
            versionNameSuffix "-dist"
            resValue("string", "application_name", "msal-dist")
        }
    }
}

dependencies {
    // Compile Dependency
    localImplementation project(':msal')
    distImplementation "com.microsoft.identity.client:msal:${msalVersion}"
    implementation "com.google.code.gson:gson:$rootProject.ext.gsonVersion"
    implementation "androidx.constraintlayout:constraintlayout:$rootProject.ext.constraintLayoutVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlinXCoroutinesVersion"
    implementation "androidx.appcompat:appcompat:$rootProject.ext.appCompatVersion"
    implementation "androidx.legacy:legacy-support-v4:$rootProject.ext.legacySupportV4Version"
    implementation "com.google.android.material:material:$rootProject.ext.materialVersion"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.kotlinVersion}"

    compileOnly "org.projectlombok:lombok:$rootProject.ext.lombokVersion"
    annotationProcessor "org.projectlombok:lombok:$rootProject.ext.lombokVersion"

    implementation("io.opentelemetry:opentelemetry-sdk:1.18.0")
}
