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

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())
    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 = SoftwareType.INTERNAL_GRADLE_PLUGIN
}

// 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
})

