/*
 * 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)
    // ensuring implementation versions stay consistent with androidTestImplementation
    def testCoreVersion = "1.5.0"
    def testRunnerVersion = "1.5.2"
    def testRulesVersion = "1.5.0"

    implementation("androidx.test:core:$testCoreVersion")
    implementation("androidx.test:rules:$testRulesVersion")
    implementation("androidx.test:runner:$testRunnerVersion")

    api("androidx.annotation:annotation:1.8.1")
    implementation(project(":camera:camera-camera2-pipe-integration"))
    api(project(":camera:camera-core"))
    api(project(":camera:camera-lifecycle"))
    api(project(":camera:camera-video"))

    implementation("androidx.appcompat:appcompat:1.1.0")
    implementation("androidx.core:core:1.1.0")
    implementation("androidx.concurrent:concurrent-futures:1.0.0")
    implementation("androidx.test.espresso:espresso-core:3.5.0")
    implementation("androidx.test.espresso:espresso-idling-resource:3.5.0")

    implementation(libs.atomicFu)
    implementation(libs.guavaListenableFuture)
    implementation(libs.junit)
    implementation(libs.truth)
    implementation(libs.kotlinStdlib)
    implementation(libs.kotlinCoroutinesAndroid)
    implementation(libs.testUiautomator)

    testImplementation("androidx.test:core:$testCoreVersion")
    testImplementation("androidx.test:runner:$testRunnerVersion")
    testImplementation(libs.junit)
    testImplementation(libs.truth)
    testImplementation(libs.robolectric)
    testImplementation(libs.mockitoCore4)

    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation("androidx.test:core:$testCoreVersion")
    androidTestImplementation("androidx.test:rules:$testRulesVersion")
    androidTestImplementation("androidx.test:runner:$testRunnerVersion")
    androidTestImplementation(libs.truth)
    androidTestImplementation(libs.kotlinStdlib)
    androidTestImplementation(libs.kotlinCoroutinesAndroid)
    androidTestImplementation("androidx.concurrent:concurrent-futures-ktx:1.1.0")
    androidTestImplementation(project(":internal-testutils-truth"))
}

android {
    compileSdk 35

    defaultConfig {
        externalNativeBuild {
            cmake {
                cppFlags "-std=c++17"
                arguments "-DCMAKE_VERBOSE_MAKEFILE=ON"
            }
        }
    }

    lintOptions {
        enable 'CameraXQuirksClassDetector'
    }

    // Use Robolectric 4.+
    testOptions.unitTests.includeAndroidResources = true

    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
            version = libs.versions.cmake.get()
        }
    }
    namespace = "androidx.camera.testing"
}

androidx {
    name = "Camera Testing"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2019"
    description = "Testing 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."
}
