/*
 * 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.KotlinTarget
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 {
    compileOnly("com.android.tools.build:gradle:7.3.0")
    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.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)
}

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 = LibraryType.GRADLE_PLUGIN
    inceptionYear = "2017"
    description = "Android Navigation TypeSafe Arguments Gradle Plugin"
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}
