/*
 * Copyright 2020 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("com.android.library")
    id("AndroidXComposePlugin")
}

androidXMultiplatform {
    android()
    desktop()

    defaultPlatform(PlatformIdentifier.ANDROID)

    sourceSets {
        commonMain {
            dependencies {
                api(project(":lifecycle:lifecycle-common"))
                api(project(":lifecycle:lifecycle-viewmodel"))
                api("androidx.annotation:annotation:1.8.1")
                api("androidx.compose.runtime:runtime:1.6.0")
                implementation(libs.kotlinStdlib)
            }
        }

        commonTest {
            // TODO(b/330323282): Move common dependencies here.
        }

        androidMain {
            dependsOn(commonMain)
            dependencies {
                api(project(":lifecycle:lifecycle-viewmodel-savedstate"))
                api("androidx.compose.ui:ui:1.6.0")
                // Converting `lifecycle-viewmodel-compose` to KMP and including a transitive
                // dependency on `lifecycle-livedata-core` triggered a Gradle bug. Adding the
                // `livedata` dependency directly works around the issue.
                // See https://github.com/gradle/gradle/issues/14220 for details.
                compileOnly(project(":lifecycle:lifecycle-livedata-core"))
            }
        }

        androidInstrumentedTest {
            dependsOn(commonTest)
            dependencies {
                implementation(project(":compose:ui:ui-test-junit4"))
                implementation(project(":compose:test-utils"))
                implementation(libs.testRules)
                implementation(libs.testRunner)
                implementation(libs.junit)
                implementation(libs.truth)
                implementation("androidx.fragment:fragment:1.3.0")
                implementation("androidx.appcompat:appcompat:1.3.0")
                // old version of common-java8 conflicts with newer version, because both have
                // DefaultLifecycleEventObserver.
                // Outside of androidx this is resolved via constraint added to lifecycle-common,
                // but it doesn't work in androidx.
                // See aosp/1804059
                implementation(project(":lifecycle:lifecycle-common-java8"))
                implementation(project(":lifecycle:lifecycle-viewmodel-savedstate"))
                implementation(project(":activity:activity-compose"))
                implementation(project(":lifecycle:lifecycle-runtime-testing"))
            }
        }
    }
}

dependencies {
    lintPublish(project(":lifecycle:lifecycle-viewmodel-compose-lint"))
}

androidx {
    name = "Lifecycle ViewModel Compose"
    type = LibraryType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS
    inceptionYear = "2021"
    description = "Compose integration with Lifecycle ViewModel"
    samples(project(":lifecycle:lifecycle-viewmodel-compose:lifecycle-viewmodel-compose-samples"))
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}

android {
    compileSdk = 35
    namespace = "androidx.lifecycle.viewmodel.compose"
}
