/*
 * Copyright 2019 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 project contains tests for code contained in buildSrc
// This project is stored outside of buildSrc/ so that waiting for these tests to complete doesn't delay the rest of the build

import androidx.build.LibraryType
import androidx.build.KotlinTarget

plugins {
    id("AndroidXPlugin")
    id("kotlin")
    id("java-gradle-plugin")
}


// We need 'java-gradle-plugin' on classpath for Gradle test kit projects. If it's not, we get the following error:
// org.gradle.testkit.runner.InvalidPluginMetadataException: Test runtime classpath does not contain
// plugin metadata file 'plugin-under-test-metadata.properties'but if we generate a .jar
//
// However, if we actually run the :jar task for buildSrc-tests we get the following warning log:
//
// :buildSrc-tests:jar: No valid plugin descriptors were found in META-INF/gradle-plugins
// so we disable it.

apply from: "../buildSrc/kotlin-dsl-dependency.gradle"

sourceSets {
    main.kotlin.srcDirs += [
            '../buildSrc/public/src/main/kotlin',
            '../buildSrc/private/src/main/kotlin',
            '../buildSrc/jetpad-integration/src/main/java'
    ]
    main.java.srcDirs += [
            '../buildSrc/jetpad-integration/src/main/java',
    ]
    main.resources.srcDirs += ['../buildSrc/private/src/main/resources']
}

apply from: "${buildscript.sourceFile.parentFile.parent}/buildSrc/shared-dependencies.gradle"

dependencies {
    api(libs.javaxInject)
    api(libs.shadow)
    api(libs.guavaAndroid)
    api(libs.kotlinGradlePluginApi)
    api(libs.kotlinNativeUtils)
    api(libs.kotlinStdlib)

    implementation(project(":benchmark:benchmark-gradle-plugin"))
    implementation(project(":inspection:inspection-gradle-plugin"))
    implementation(project(":stableaidl:stableaidl-gradle-plugin"))
    implementation(project(":binarycompatibilityvalidator:binarycompatibilityvalidator"))
    implementation(project.ext.findGradleKotlinDsl())
    // Workaround for targeting KotlinTarget.KOTLIN_1_9, but linking agaist kotlin compiler
    // embeddable 2.0 in buildSrc
    implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${libs.versions.kotlin.get()}")
    implementation(libs.kotlinGradlePluginAnnotations)
    implementation(libs.kotlinToolingCore)
    implementation(libs.binaryCompatibilityValidator)
    implementation(libs.jetbrainsBinaryCompatibilityValidator)
    implementation(libs.xmlApis)

    testImplementation(libs.checkmark)
    testImplementation libs.hamcrestCore
    testImplementation(libs.junit)
    testImplementation(libs.truth)
    testImplementation(project(":internal-testutils-gradle-plugin"))
    testImplementation(project(":internal-testutils-truth"))
    testImplementation(gradleTestKit())
}

tasks.withType(Test).configureEach {
    // https://github.com/gradle/gradle/issues/22317
    it.jvmArgs = ["--add-opens=java.base/java.lang=ALL-UNNAMED"]
}

androidx {
    type = LibraryType.INTERNAL_GRADLE_PLUGIN
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}

// Also do style checking of the buildSrc project from within this project
// We run that from this project so that it doesn't block other projects while it runs
def ktfmtDir = file("../buildSrc")
def subdirs = ["plugins", "private", "public"]

tasks["ktCheck"].configure({ t ->
    t.overrideDirectory = ktfmtDir
    t.overrideSubdirectories = subdirs
})
tasks["ktFormat"].configure({ t ->
    t.overrideDirectory = ktfmtDir
    t.overrideSubdirectories = subdirs
})

