/*
 * Copyright 2022 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")
    id("java-gradle-plugin")
}

// This custom configuration ensures that dependencies used in tests with gradle test kit with
// generated build.gradle are considered when determining which tests to run on CI due to a change.
// For reference: b/281515796
configurations {
    neededForGradleTestKit {
        canBeResolved = true
    }
    neededForGradleTestKitAgp80 {
        canBeResolved = true
    }
    neededForGradleTestKitAgp81 {
        canBeResolved = true
    }
}

dependencies {
    compileOnly(libs.androidGradlePlugin)
    compileOnly(libs.kotlinGradlePlugin)

    implementation(gradleApi())
    implementation("com.google.protobuf:protobuf-java:3.22.3")
    implementation(libs.agpTestingPlatformCoreProto)

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

    neededForGradleTestKit(libs.androidGradlePlugin)
    neededForGradleTestKit(libs.kotlinGradlePlugin)
    neededForGradleTestKit(libs.kotlinStdlib)

    neededForGradleTestKitAgp80("com.android.tools.build:gradle:8.0.0")
    neededForGradleTestKitAgp80("com.android.tools.build:aapt2:8.0.0-9289358")
    neededForGradleTestKitAgp80("com.android.tools.build:aapt2:8.0.0-9289358:linux")
    neededForGradleTestKitAgp80("com.android.tools.build:aapt2:8.0.0-9289358:osx")
    neededForGradleTestKitAgp81("com.android.tools.build:gradle:8.1.0")
    neededForGradleTestKitAgp81("com.android.tools.build:aapt2:8.1.0-10154469")
    neededForGradleTestKitAgp81("com.android.tools.build:aapt2:8.1.0-10154469:linux")
    neededForGradleTestKitAgp81("com.android.tools.build:aapt2:8.1.0-10154469:osx")
}

tasks.withType(Test).configureEach {
    it.dependsOn(configurations.neededForGradleTestKit)
    it.dependsOn(configurations.neededForGradleTestKitAgp80)
    it.dependsOn(configurations.neededForGradleTestKitAgp81)
}

gradlePlugin {
    plugins {
        baselineProfileProducer {
            id = "androidx.baselineprofile.producer"
            implementationClass = "androidx.baselineprofile.gradle.producer.BaselineProfileProducerPlugin"
        }
        baselineProfileConsumer {
            id = "androidx.baselineprofile.consumer"
            implementationClass = "androidx.baselineprofile.gradle.consumer.BaselineProfileConsumerPlugin"
        }
        baselineProfileAppTarget {
            id = "androidx.baselineprofile.apptarget"
            implementationClass = "androidx.baselineprofile.gradle.apptarget.BaselineProfileAppTargetPlugin"
        }
        baselineProfileWrapper {
            id = "androidx.baselineprofile"
            implementationClass = "androidx.baselineprofile.gradle.wrapper.BaselineProfileWrapperPlugin"
        }
    }
}

androidx {
    name = "Baseline Profile Gradle Plugin"
    type = LibraryType.GRADLE_PLUGIN
    inceptionYear = "2022"
    description = "Android Baseline Profile Gradle Plugin"
}

tasks.withType(Test).configureEach { test ->
    test.maxParallelForks = 2
    test.javaLauncher = javaToolchains.launcherFor {
        // Test on JDK 17 which supports lower versions of AGP. This can be removed
        // once we move to AGP 8.2.1+
        languageVersion = JavaLanguageVersion.of(17)
    }
}
afterEvaluate { tasks.named("test") { it.dependsOn(tasks.named("publish")) } }
