/*
 * Copyright (C) 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.KotlinTarget
import androidx.build.LibraryType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

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

dependencies {
    api(libs.kotlinStdlibJdk8)
    api(libs.javapoet)
    api(libs.kotlinPoet)
    api(libs.kotlinPoetJavaPoet)
    implementation(libs.guava)
    implementation(libs.autoCommon)
    implementation(libs.autoValueAnnotations)
    implementation(libs.kotlinMetadataJvm)
    implementation(libs.kspApi)

    testImplementation("androidx.annotation:annotation:1.8.1")
    testImplementation(libs.googleCompileTesting)
    testImplementation(libs.junit)
    testImplementation(libs.jsr250)
    testImplementation(libs.kotlinMetadataJvm) // Due to being shadowed in main dependency
    testImplementation(libs.testParameterInjector)
    testImplementation(project(":room:room-compiler-processing-testing"))
    testImplementation(project(":internal-testutils-common"))
    testImplementation(project(":kruth:kruth"))
}

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

tasks.withType(Test).configureEach { test ->
    test.maxParallelForks = 2
    test.systemProperty("androidx.room.compiler.processing.strict", "true")
    // With the move to K2 and KSP2 the memory usage has increased so we enlarge the heap
    // to prevent OOM while running all the tests in one go.
    test.maxHeapSize = "8g"
}

androidx {
    name = "Room XProcessor"
    type = LibraryType.ANNOTATION_PROCESSOR_UTILS
    inceptionYear = "2020"
    description = "Processing Environment Abstraction for AndroidX Room"
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}
