/*
 * 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(libs.guavaListenableFuture)
    api(project(":camera:camera-core"))
    implementation("androidx.core:core:1.0.0")
    implementation("androidx.concurrent:concurrent-futures:1.0.0")
    implementation(libs.autoValueAnnotations)
    annotationProcessor(libs.autoValue)

    compileOnly(project(":camera:camera-extensions-stub"))

    testImplementation(libs.junit)
    testImplementation(libs.mockitoCore4)
    testImplementation(libs.robolectric)
    testImplementation(libs.truth)
    testImplementation(project(":camera:camera-testing"))
    testImplementation(project(":camera:camera-extensions-stub"))
    testImplementation(libs.testCore)
    testImplementation(libs.testRunner)
    testImplementation(libs.truth)

    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.testCore)
    androidTestImplementation(libs.testRules)
    androidTestImplementation(libs.dexmakerMockito)
    androidTestImplementation(libs.kotlinCoroutinesAndroid)
    androidTestImplementation(libs.kotlinStdlib)
    androidTestImplementation(libs.mockitoCore)
    androidTestImplementation(libs.testUiautomator)
    androidTestImplementation(libs.truth)
    androidTestImplementation(project(":camera:camera-camera2"))
    androidTestImplementation(project(":camera:camera-camera2-pipe-integration"))
    androidTestImplementation(project(":camera:camera-lifecycle"))
    androidTestImplementation(project(":camera:camera-testing")) {
        // Ensure camera-testing does not pull in androidx.test dependencies
        exclude(group:"androidx.test")
    }
    androidTestImplementation(project(":camera:camera-video"))
    androidTestImplementation(project(":internal-testutils-truth"))
    androidTestImplementation(project(":camera:camera-testlib-extensions"))
    androidTestImplementation("androidx.concurrent:concurrent-futures-ktx:1.1.0")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0")
    // To use the testlib to have the implementation of the extensions-stub interface.
}

android {
    compileSdk = 35

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

    lintOptions {
        enable 'CameraXQuirksClassDetector'
    }

    // Use Robolectric 4.+
    testOptions.unitTests.includeAndroidResources = true
    namespace = "androidx.camera.extensions"
}

androidx {
    name = "Camera Extensions"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2019"
    description = "OEM Extensions for the Jetpack Camera Library, a library providing interfaces" +
            " to integrate with OEM specific camera features."
}
