/*
 * Copyright (C) 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.LibraryType
import androidx.build.PlatformIdentifier

plugins {
    id("AndroidXPlugin")
}

androidXMultiplatform {
    androidLibrary {
        namespace = "androidx.testutils.lifecycle"
        withAndroidTestOnDeviceBuilder {
            it.compilationName = "instrumentedTest"
            it.defaultSourceSetName = "androidInstrumentedTest"
            it.sourceSetTreeName = "test"
        }
        withAndroidTestOnJvmBuilder {
            it.defaultSourceSetName = "androidUnitTest"
        }
    }
    desktop()
    mac()
    linux()
    ios()

    defaultPlatform(PlatformIdentifier.ANDROID)

    sourceSets {
        commonMain {
            dependencies {
                api(project(":lifecycle:lifecycle-runtime"))
                api("androidx.annotation:annotation:1.8.1")

                api(libs.kotlinStdlib)
                api(libs.kotlinCoroutinesCore)
                api(libs.kotlinCoroutinesTest)
            }
        }

        androidMain {
            dependsOn(commonMain)
            dependencies {
                api(libs.testRules)
                implementation(libs.testExtJunit)
                implementation(libs.testCore)
            }
        }
    }
}


androidx {
    type = LibraryType.INTERNAL_TEST_LIBRARY
}
