/*
 * Copyright 2024 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.PlatformIdentifier

plugins {
    id("AndroidXPlugin")
    id("AndroidXComposePlugin")
    id("com.android.library")
}

androidXMultiplatform {
    android()
    jvmStubs()

    defaultPlatform(PlatformIdentifier.ANDROID)

    sourceSets {
        commonMain {
            dependencies {
                implementation(libs.kotlinStdlib)
                implementation("androidx.collection:collection-ktx:1.4.5")
                implementation("androidx.compose.runtime:runtime:1.7.5")
                implementation("androidx.compose.runtime:runtime-saveable:1.7.5")
                implementation("androidx.lifecycle:lifecycle-runtime:2.8.7")
                implementation(project(":savedstate:savedstate"))
                implementation(project(":savedstate:savedstate-compose"))
            }
        }

        commonTest {
            dependencies {
                implementation(libs.kotlinTest)
                implementation(project(":kruth:kruth"))
                implementation(project(":compose:runtime:runtime-test-utils"))
            }
        }

        jvmMain {
            dependsOn(commonMain)
            dependencies {
            }
        }

        androidMain {
            dependsOn(jvmMain)
            dependencies {
                api("androidx.compose.animation:animation:1.7.5")
                api("androidx.compose.ui:ui:1.7.5")
                implementation("androidx.activity:activity-compose:1.9.3")
                implementation("androidx.annotation:annotation:1.8.0")
            }
        }

        jvmTest {
            dependsOn(commonTest)
            dependencies {
            }
        }

        androidInstrumentedTest {
            dependsOn(jvmTest)
            dependencies {
                implementation(libs.testRules)
                implementation(libs.testRunner)
                implementation(libs.junit)
                implementation(libs.testExtJunitKtx)
                implementation(libs.truth)
                implementation("androidx.compose.material3:material3:1.3.1")
                implementation(project(":compose:test-utils"))
                implementation("androidx.compose.ui:ui-test:1.7.5")
                implementation("androidx.compose.ui:ui-test-junit4:1.7.5")
            }
        }

        commonStubsMain {
            dependsOn(commonMain)
        }

        jvmStubsMain {
            dependsOn(commonStubsMain)
        }
    }
}

android {
    compileSdk = 35
    namespace = "androidx.navigation3"
}

androidx {
    name = "Androidx Navigation 3"
    type = LibraryType.SNAPSHOT_ONLY_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS
    inceptionYear = "2024"
    description = "Provides the building blocks for a Compose first Navigation solution that " +
            "easily supports extensions."
    samples(project(":navigation3:navigation3:navigation3-samples"))
    doNotDocumentReason = "Not published to maven"
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}
