/*
 * Copyright (C) 2025 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.KotlinTarget
import androidx.build.LibraryType

plugins {
    id("AndroidXPlugin")
    id("kotlin")
}

androidx.configureAarAsJarForConfiguration("testImplementation")

dependencies {
    api(libs.kotlinStdlib)
    implementation(libs.kspApi)
    implementation(libs.kotlinPoet)

    testImplementationAarAsJar(project(":appfunctions:appfunctions-common"))
    testImplementationAarAsJar(project(":appfunctions:appfunctions-runtime"))
    testImplementation(libs.googleCompileTesting)
    testImplementation(project(":room:room-compiler-processing-testing"))
    testImplementation(libs.junit)
    testImplementation(libs.truth)
}

def testGeneratedSourcesPath = "${layout.buildDirectory.get().asFile}/testGeneratedSources"
tasks.withType(Test).configureEach { test ->
    test.doFirst {
        systemProperty("test_output_dir", testGeneratedSourcesPath)
    }
}

androidx {
    name = "androidx.appfunctions:appfunctions-compiler"
    type = LibraryType.ANNOTATION_PROCESSOR
    inceptionYear = "2025"
    description = "AppFunction Compiler"
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}
