/*
 * 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 {
    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."
}
