/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * 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.
 */

/**
 * This file was created using the `create_project.py` script located in the
 * `<AndroidX root>/development/project-creator` directory.
 *
 * Please use that script when creating a new project, rather than copying an existing project and
 * modifying its settings.
 */

import androidx.build.KotlinTarget
import androidx.build.LibraryType

plugins {
    id("AndroidXPlugin")
    id("com.android.library")
    id("org.jetbrains.kotlin.android")
}

dependencies {
    api(libs.kotlinStdlib)
    api(project(":credentials:credentials"))

    implementation("com.google.android.libraries.identity.googleid:googleid:1.1.0"){
        exclude group: "androidx.credentials"
    }

    // Closed source dependencies
    implementation(libs.playServicesAuth){
        exclude group: "androidx.loader"
        exclude group: "androidx.core"
    }

    implementation(libs.playServicesFido){
        exclude group: "androidx.loader"
        exclude group: "androidx.core"
    }

    implementation(libs.playServicesBlockstore){
        exclude group: "androidx.loader"
        exclude group: "androidx.core"
    }

    implementation(libs.playServicesIdentityCredentials){
        exclude group: "androidx.loader"
        exclude group: "androidx.core"
    }

    androidTestImplementation(libs.junit)
    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testCore)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.testRules)
    androidTestImplementation(libs.mockitoAndroid)
    androidTestImplementation(libs.truth)
    androidTestImplementation(project(":internal-testutils-truth"))
    androidTestImplementation(libs.kotlinCoroutinesAndroid)
    androidTestImplementation("androidx.core:core-ktx:1.10.0")
    androidTestImplementation("androidx.fragment:fragment:1.5.7")
    androidTestImplementation("androidx.fragment:fragment-ktx:1.5.7")
}


android {
    compileSdk = 35
    namespace = "androidx.credentials.play.services.auth"

    buildTypes.configureEach {
        consumerProguardFiles "proguard-rules.pro"
    }
}

androidx {
    name = "Credentials Play Services Auth"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2022"
    description = "sign into apps using play-services-auth library"
    legacyDisableKotlinStrictApiMode = true
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}
