/*
 * 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.LibraryType

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

dependencies {
    implementation(project(":lifecycle:lifecycle-common"))
    implementation(libs.kotlinStdlib)
    implementation(libs.autoCommon)
    implementation(libs.javapoet)
    testImplementation(libs.googleCompileTesting)
    testImplementation(libs.jsr250)
}

// The following tasks are used to create test-library.jar used by ValidCasesTest.kt
// We actually need to compile :lifecycle:lifecycle-common, but compileJava is easier
def compileTestLibrarySource = tasks.register("compileTestLibrarySource", JavaCompile) {
    it.dependsOn(compileJava)
    it.source "src/test/test-data/lib/src"
    it.classpath = project.compileJava.classpath
    it.destinationDirectory.set(layout.buildDirectory.dir("test-data-lib-classes"))
}

def testLibraryJar = tasks.register("jarTestLibrarySource", Jar) {
    it.from(compileTestLibrarySource.map { it.destinationDirectory })
    it.archiveFileName.set("test-library.jar")
    it.destinationDirectory.set(layout.buildDirectory.dir("test-data-lib-jar"))
}

sourceSets.test.output.dir(testLibraryJar.map { it.destinationDirectory })

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 = "Lifecycles Compiler"
    type = LibraryType.ANNOTATION_PROCESSOR
    inceptionYear = "2017"
    description = "Android Lifecycles annotation processor"
}
