/*
 * Copyright (C) 2024 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("AndroidXComposePlugin")
    id("com.android.library")
    id("org.jetbrains.kotlin.android")
}

dependencies {
    api(project(":camera:camera-core"))
    // TODO(b/357895362): Switch to pinned dependencies when stable is released
    api(project(":camera:viewfinder:viewfinder-compose"))
    api(project(":camera:viewfinder:viewfinder-core"))
    implementation("androidx.compose.foundation:foundation-layout:1.6.1")
    implementation("androidx.compose.foundation:foundation:1.6.1")
    implementation("androidx.compose.runtime:runtime:1.6.1")
    implementation("androidx.core:core-ktx:1.12.0")

    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.testRules)
    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("androidx.compose.ui:ui-test-junit4:1.6.1")
    androidTestImplementation("androidx.compose.ui:ui-test-manifest:1.6.1")
}

android {
    compileSdk = 35
    namespace = "androidx.camera.compose"
    // TODO(b/349411310): Remove once we can update runtime to 1.7.0
    experimentalProperties["android.lint.useK2Uast"] = false
}

androidx {
    name = "Camera Compose"
    type = LibraryType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS
    samples(project(":camera:camera-compose:camera-compose-samples"))
    inceptionYear = "2024"
    description = "Jetpack Compose tools for users of the Jetpack Camera camera-core library"
}
