/*
 * Copyright (C) 2017 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
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 {
    compileOnly("com.android.tools.build:gradle:8.4.2")
    implementation(libs.kotlinStdlib)
    implementation(project(":navigation:navigation-safe-args-generator"))
    implementation(gradleApi())
    implementation(libs.gson)

    testImplementation(gradleTestKit())
    testImplementation(project(":internal-testutils-gradle-plugin"))
    testImplementation(libs.hamcrestCore)
    testImplementation(libs.junit)
    testPlugin("com.android.tools.build:gradle:8.4.2")
    testPlugin("com.android.tools.build:aapt2:8.4.2-11315950")
    testPlugin("com.android.tools.build:aapt2:8.4.2-11315950:linux")
    testPlugin("com.android.tools.build:aapt2:8.4.2-11315950:osx")
    testPlugin(libs.kotlinGradlePlugin)
}

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

gradlePlugin {
    plugins {
        safeargsJava {
            id = "androidx.navigation.safeargs"
            implementationClass = "androidx.navigation.safeargs.gradle.SafeArgsJavaPlugin"
        }
        safeargsKotlin {
            id = "androidx.navigation.safeargs.kotlin"
            implementationClass = "androidx.navigation.safeargs.gradle.SafeArgsKotlinPlugin"
        }
    }
}

androidx {
    name = "Navigation TypeSafe Arguments Gradle Plugin"
    type = SoftwareType.GRADLE_PLUGIN
    inceptionYear = "2017"
    description = "Android Navigation TypeSafe Arguments Gradle Plugin"
}
