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

plugins {
    id("AndroidXPlugin")
}

androidXMultiplatform {
    androidLibrary {
        namespace = "androidx.lifecycle.testing"
        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(libs.kotlinStdlib)
                api(project(":lifecycle:lifecycle-runtime"))
            }
        }

        commonTest {
            dependencies {
                implementation(libs.kotlinCoroutinesTest)
                implementation(libs.kotlinTest)
                implementation(project(":kruth:kruth"))
            }
        }

        androidInstrumentedTest {
            dependencies {
                implementation(libs.truth)
                implementation(libs.testExtJunit)
                implementation(libs.testCore)
                implementation(libs.testRunner)
                implementation(libs.kotlinCoroutinesTest)
            }
        }
    }
}

dependencies {
    lintPublish(project(":lifecycle:lifecycle-runtime-testing-lint"))
}

androidx {
    name = "Lifecycle Runtime Testing"
    type = LibraryType.PUBLISHED_TEST_LIBRARY
    inceptionYear = "2019"
    description = "Testing utilities for 'lifecycle' artifact"
}

