/*
 * Copyright 2019 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.LibraryType

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

dependencies {
    api(libs.jspecify)
    api("androidx.lifecycle:lifecycle-common:2.1.0")
    api(libs.guavaListenableFuture)
    api(project(":camera:camera-core"))
    implementation("androidx.core:core:1.1.0")
    implementation(libs.autoValueAnnotations)
    implementation(libs.kotlinCoroutinesAndroid)
    implementation("androidx.concurrent:concurrent-futures:1.1.0")
    implementation("androidx.concurrent:concurrent-futures-ktx:1.1.0")
    implementation("androidx.tracing:tracing-ktx:1.2.0")

    annotationProcessor(libs.autoValue)

    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testCore)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.testRules)
    androidTestImplementation(libs.truth)
    androidTestImplementation(project(":camera:camera-testing")) {
        // Ensure camera-testing does not pull in androidx.test dependencies
        exclude(group:"androidx.test")
    }
    androidTestImplementation(libs.kotlinStdlib)
    androidTestImplementation(libs.kotlinCoroutinesAndroid)
    androidTestImplementation("androidx.annotation:annotation-experimental:1.4.1")
    androidTestImplementation("androidx.concurrent:concurrent-futures-ktx:1.1.0")
    androidTestImplementation(project(":internal-testutils-truth"))
    androidTestImplementation("org.jetbrains.kotlinx:atomicfu:0.13.1")
}

android {
    compileSdk = 35

    lintOptions {
        enable 'CameraXQuirksClassDetector'
    }
    // Use Robolectric 4.+
    testOptions.unitTests.includeAndroidResources = true
    namespace = "androidx.camera.lifecycle"
}

androidx {
    name = "Camera Lifecycle"
    type = LibraryType.PUBLISHED_LIBRARY
    samples(project(":camera:camera-lifecycle:camera-lifecycle-samples"))
    inceptionYear = "2019"
    description = "Lifecycle components for the Jetpack Camera Library, a library providing a " +
            "consistent and reliable camera foundation that enables great camera driven " +
            "experiences across all of Android."
    samples(project(":camera:camera-lifecycle:camera-lifecycle-samples"))
}
