/*
 * 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.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-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-app-compiler"
    type = LibraryType.ANNOTATION_PROCESSOR
    inceptionYear = "2024"
    description = "AppFunction App Compiler"
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}
