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

androidXMultiplatform {
    android()
    desktop()
    ios()
    linux()
    mac()

    defaultPlatform(PlatformIdentifier.ANDROID)

    sourceSets {
        commonMain {
            dependencies {
                api("androidx.annotation:annotation:1.8.1")
                api(project(":savedstate:savedstate"))
                api(project(":lifecycle:lifecycle-viewmodel"))
                api(libs.kotlinStdlib)
                api(libs.kotlinCoroutinesCore)
                api(libs.kotlinSerializationCore)
            }
        }

        commonTest {
            dependencies {
                implementation(project(":lifecycle:lifecycle-runtime"))
                implementation(libs.kotlinCoroutinesTest)
            }
        }

        jvmMain {
            dependsOn(commonMain)
        }

        jvmTest {
            dependsOn(commonTest)
        }

        androidMain {
            dependsOn(jvmMain)
            dependencies {
                api("androidx.core:core-ktx:1.2.0")
                api(project(":lifecycle:lifecycle-livedata-core"))
                api(libs.kotlinCoroutinesAndroid)
            }
        }

        androidUnitTest {
            dependsOn(jvmTest)
        }

        androidInstrumentedTest {
            dependsOn(jvmTest)
            dependencies {
                implementation(project(":lifecycle:lifecycle-livedata-core"))
                implementation ("androidx.fragment:fragment:1.3.0")
                implementation(project(":internal-testutils-runtime"))
                implementation(project(":lifecycle:lifecycle-viewmodel"))
                implementation(libs.truth)
                implementation(libs.testExtJunit)
                implementation(libs.testCore)
                implementation(libs.testRunner)
                implementation(libs.testRules)
            }
        }

        nonAndroidMain {
            dependsOn(commonMain)
        }

        nonAndroidTest {
            dependsOn(commonTest)
        }

        desktopMain {
            dependsOn(jvmMain)
            dependsOn(nonAndroidMain)
        }

        desktopTest {
            dependsOn(jvmTest)
            dependsOn(nonAndroidTest)
        }

        nativeMain {
            dependsOn(commonMain)
            dependsOn(nonAndroidMain)
        }

        nativeTest {
            dependsOn(commonTest)
            dependsOn(nonAndroidTest)
        }

        darwinMain {
            dependsOn(nativeMain)
        }

        darwinTest {
            dependsOn(nativeTest)
        }

        linuxMain {
            dependsOn(nativeMain)
        }

        linuxTest {
            dependsOn(nativeTest)
        }

        targets.configureEach { target ->
            if (target.platformType == org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.native) {
                target.compilations["main"].defaultSourceSet {
                    def konanTargetFamily = target.konanTarget.family
                    if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.OSX || konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.IOS) {
                        dependsOn(darwinMain)
                    } else if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.LINUX) {
                        dependsOn(linuxMain)
                    } else {
                        throw new GradleException("unknown native target ${target}")
                    }
                }
                target.compilations["test"].defaultSourceSet {
                    def konanTargetFamily = target.konanTarget.family
                    if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.OSX || konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.IOS) {
                        dependsOn(darwinTest)
                    } else if (konanTargetFamily == org.jetbrains.kotlin.konan.target.Family.LINUX) {
                        dependsOn(linuxTest)
                    } else {
                        throw new GradleException("unknown native target ${target}")
                    }
                }
            }
        }
    }
}


android {
    buildTypes.configureEach {
        consumerProguardFiles("proguard-rules.pro")
    }
    namespace = "androidx.lifecycle.viewmodel.savedstate"
    experimentalProperties["android.lint.useK2Uast"] = false // TODO(b/345531033)
}

androidx {
    name = "Lifecycle ViewModel with SavedState"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2018"
    description = "Android Lifecycle ViewModel"
    samples(project(":lifecycle:lifecycle-viewmodel-savedstate-samples"))
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}
