/*
 * Copyright 2020 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.SoftwareType
import androidx.build.SdkHelperKt
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

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

androidx.configureAarAsJarForConfiguration("testImplementation")

dependencies {
    implementation(libs.kotlinStdlib)
    implementation("androidx.room:room-compiler-processing:2.6.0")
    implementation(libs.javapoet)
    implementation(libs.kspApi)

    testImplementation(project(":hilt:hilt-common"))
    testImplementation("androidx.annotation:annotation:1.8.1")
    testImplementation(libs.junit)
    testImplementation(libs.truth)
    testImplementation(project(":room:room-compiler-processing-testing"))
    testImplementation(libs.hiltCore)
    testImplementationAarAsJar(project(":hilt:hilt-work"))
    testImplementation(SdkHelperKt.getSdkDependency(project))
}

tasks.withType(KotlinCompile).configureEach {
    kotlinOptions {
        freeCompilerArgs += [
                "-opt-in=androidx.room.compiler.processing.ExperimentalProcessingApi",
                "-opt-in=com.squareup.kotlinpoet.javapoet.KotlinPoetJavaPoetPreview"
        ]
    }
}

tasks.withType(Test).configureEach {
    // https://github.com/google/compile-testing/issues/222
    it.jvmArgs "--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"
}

androidx {
    name = "Hilt Extension Compiler"
    type = SoftwareType.ANNOTATION_PROCESSOR
    mavenVersion = LibraryVersions.HILT
    inceptionYear = "2020"
    description = "AndroidX Hilt Extension Compiler"
}
