/*
 * 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")
    alias(libs.plugins.kotlinSerialization)
}

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")
                api(libs.kotlinSerializationCore)
                implementation(libs.kotlinStdlib)
            }
        }

        commonTest {
            dependencies {
                implementation(project(":lifecycle:lifecycle-viewmodel-savedstate"))
                implementation(project(":lifecycle:lifecycle-viewmodel-testing"))
                implementation(project(":lifecycle:lifecycle-runtime-testing"))
            }
        }

        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(":activity:activity-compose"))
            }
        }
    }
}

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