/*
 * Copyright (C) 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.annotation:annotation:1.8.1")
    api("androidx.core:core:1.6.0")
    implementation("androidx.collection:collection:1.4.2")
    api("androidx.vectordrawable:vectordrawable:1.1.0")
    api("androidx.vectordrawable:vectordrawable-animated:1.1.0")

    androidTestImplementation(libs.kotlinStdlib)
    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testCore)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.testRules)
    androidTestImplementation(libs.truth)
    androidTestImplementation(libs.espressoCore)
    androidTestImplementation(libs.mockitoCore)
    androidTestImplementation(libs.dexmakerMockito)
    androidTestImplementation(project(":internal-testutils-runtime"), {
        exclude group: "androidx.appcompat", module: "appcompat-resources"
    })
}

android {
    defaultConfig {
        // This disables the builds tools automatic vector -> PNG generation
        generatedDensities = []
    }

    aaptOptions {
        additionalParameters "--no-version-vectors"
        noCompress "ttf"
    }
    namespace = "androidx.appcompat.resources"
}

androidx {
    name = "AppCompat Resources"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2019"
    description = "Provides backward-compatible implementations of resource-related Android SDK" +
            "functionality, including color state list theming."
}
