/*
 * Copyright 2023 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
import androidx.build.SdkResourceGenerator

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

configurations {
    // Config for plugin classpath to be used during tests
    testPlugin {
        canBeConsumed = false
        canBeResolved = true
    }
}

dependencies {
    implementation(libs.kotlinStdlib)
    implementation(gradleApi())
    compileOnly("com.android.tools.build:gradle:8.1.0")
    compileOnly(libs.kotlinGradlePlugin)
    compileOnly(libs.kspGradlePlugin)

    testImplementation(project(":internal-testutils-gradle-plugin"))
    testImplementation(gradleTestKit())
    testImplementation(libs.junit)
    testImplementation(project(":kruth:kruth"))
    testImplementation(libs.testParameterInjector)

    testPlugin("com.android.tools.build:gradle:8.1.0")
    testPlugin("com.android.tools.build:aapt2:8.1.0-10154469")
    testPlugin("com.android.tools.build:aapt2:8.1.0-10154469:linux")
    testPlugin("com.android.tools.build:aapt2:8.1.0-10154469:osx")
    testPlugin(libs.kotlinGradlePlugin)
    testPlugin(libs.kspGradlePlugin)
}

// Configure the generating task of plugin-under-test-metadata.properties to
// include additional dependencies for the injected plugin classpath that
// are not present in the main runtime dependencies. This allows us to test
// the KAPT / KSP plugins while keeping a compileOnly dep on the main source.
tasks.withType(PluginUnderTestMetadata.class).named("pluginUnderTestMetadata").configure {
    it.pluginClasspath.from(configurations.testPlugin)
}

tasks.withType(Test).configureEach { test ->
    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)
    }
    // Configure publishing tasks to be dependencies of 'test' so those artifacts are available for
    // the test project executed with Gradle Test Kit.
    test.dependsOn(
            ":annotation:annotation:publish",
            ":collection:collection:publish",
            ":annotation:annotation-experimental:publish",
            ":collection:collection:publish",
            ":room:room-common:publish",
            ":room:room-runtime:publish",
            ":room:room-migration:publish",
            ":room:room-compiler:publish",
            ":room:room-compiler-processing:publish",
            ":room:room-external-antlr:publish",
            ":sqlite:sqlite:publish",
            ":sqlite:sqlite-framework:publish",
    )
}

gradlePlugin {
    plugins {
        room {
            id = "androidx.room"
            implementationClass = "androidx.room.gradle.RoomGradlePlugin"
        }
    }
}

androidx {
    name = "Room Gradle Plugin"
    type = LibraryType.GRADLE_PLUGIN
    inceptionYear = "2023"
    description = "Android Room Gradle Plugin"
}
