/*
 * Copyright (C) 2018 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("java-library")
}

androidx.configureAarAsJarForConfiguration("testImplementation")

dependencies {
    api(libs.jspecify)
    api("androidx.annotation:annotation:1.1.0")
    api(libs.jsr250)
    implementation(libs.autoCommon)
    implementation(libs.autoService)
    implementation(libs.autoServiceAnnotations)
    implementation(libs.autoValue)
    implementation(libs.autoValueAnnotations)
    implementation(libs.guava)
    implementation(libs.javapoet)
    implementation(libs.kotlinMetadataJvm)

    annotationProcessor(libs.autoValue)

    // For testing, add in the compiled classes from appsearch to get access to annotations.
    testImplementationAarAsJar(project(":appsearch:appsearch"))
    testImplementation(libs.googleCompileTesting)
    testImplementation(project(":room:room-compiler-processing-testing"))
    testImplementation(libs.kotlinCompilerEmbeddable)
    testImplementation(libs.kotlinCompileTestingKsp)
}

androidx {
    name = "AppSearch Compiler"
    type = LibraryType.ANNOTATION_PROCESSOR
    inceptionYear = '2019'
    description = 'Compiler for classes annotated with @androidx.appsearch.annotation.Document'
    failOnDeprecationWarnings = false
}
