/*
 * build.gradle
 *
 * Copyright (c) 2016 Auth0 (http://auth0.com)
 *
 * 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.
 */

plugins {
    id 'com.android.library'
    id 'kotlin-android'
}

apply from: rootProject.file('gradle/versioning.gradle')

version = getVersionFromFile()

logger.lifecycle("Using version ${version} for ${name}")

android {
    compileSdk 35

    defaultConfig {
        minSdkVersion 21
        targetSdk 35
        versionCode 1
        versionName project.version

        buildConfigField "String", "LIBRARY_NAME", "\"$project.rootProject.name\""
        buildConfigField "String", "VERSION_NAME", "\"${project.version}\""

        manifestPlaceholders = [auth0Domain: '${auth0Domain}', auth0Scheme: '${auth0Scheme}']

        consumerProguardFiles '../proguard/proguard-gson.pro', '../proguard/proguard-okio.pro', '../proguard/proguard-jetpack.pro'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        htmlReport true
        abortOnError true
    }
    testOptions {
        unitTests {
            all {
                maxHeapSize = "1024m"
            }
            includeAndroidResources = true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
        freeCompilerArgs += [
                '-Xexplicit-api=strict', // or '-Xexplicit-api=warning'
        ]
    }
}

ext {
    okhttpVersion = '4.12.0'
    powermockVersion = '2.0.9'
    coroutinesVersion = '1.6.2'
    biometricLibraryVersion = '1.1.0'
    credentialManagerVersion = "1.3.0"
}


dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.6.0'
    implementation 'androidx.browser:browser:1.4.0'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
    implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"

    implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
    implementation 'com.google.code.gson:gson:2.8.9'
    implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.4.0'

    implementation "androidx.biometric:biometric:$biometricLibraryVersion"

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
    testImplementation "org.powermock:powermock-module-junit4:$powermockVersion"
    testImplementation "org.powermock:powermock-module-junit4-rule:$powermockVersion"
    testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"
    testImplementation 'org.mockito:mockito-core:3.12.4'
    // Mockito-Kotlin: See https://github.com/nhaarman/mockito-kotlin/wiki/Parameter-specified-as-non-null-is-null
    testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0'
    testImplementation "com.squareup.okhttp3:mockwebserver:$okhttpVersion"
    testImplementation "com.squareup.okhttp3:okhttp-tls:$okhttpVersion"
    testImplementation 'com.jayway.awaitility:awaitility:1.7.0'
    testImplementation 'org.robolectric:robolectric:4.8.1'
    testImplementation 'androidx.test.espresso:espresso-intents:3.5.1'
    testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"

    testImplementation "androidx.biometric:biometric:$biometricLibraryVersion"

    implementation "androidx.credentials:credentials-play-services-auth:$credentialManagerVersion"
    implementation "androidx.credentials:credentials:$credentialManagerVersion"
}

apply from: rootProject.file('gradle/jacoco.gradle')
apply from: rootProject.file('gradle/maven-publish.gradle')