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

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