/*
 * Copyright 2019 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

plugins {
    id("AndroidXPlugin")
    id("com.android.library")
    id("AndroidXComposePlugin")
}

androidXMultiplatform {
    android()
    desktop()

    sourceSets {
        commonMain {
            dependencies {
                implementation(libs.kotlinStdlibCommon)
                implementation(project(":compose:runtime:runtime"))
                implementation(project(":compose:ui:ui-unit"))
                implementation(project(":compose:ui:ui-graphics"))
                implementation(project(":compose:ui:ui-test-junit4"))
            }
        }
        androidMain.dependencies {
            api("androidx.activity:activity:1.7.1")
            // workaround for https://github.com/gradle/gradle/issues/8489
            implementation("androidx.lifecycle:lifecycle-common:2.6.1")
            implementation "androidx.activity:activity-compose:1.3.1"
            api(project(":compose:ui:ui-test-junit4"))
            api(project(":test:screenshot:screenshot"))
            // This has stub APIs for access to legacy Android APIs, so we don't want
            // any dependency on this module.
            compileOnly(project(":compose:ui:ui-android-stubs"))
            implementation(libs.testCore)
            implementation(libs.testRules)
        }

        commonTest {
            dependencies {
            }
        }

        jvmMain {
            dependsOn(commonMain)
            dependencies {
            }
        }


        androidMain {
            dependsOn(jvmMain)
            dependencies {
            }
        }

        desktopMain {
            dependsOn(jvmMain)
            dependencies {
            }
        }

        androidInstrumentedTest {
            dependsOn(commonTest)
            dependencies {
                implementation(libs.truth)
                implementation(project(":compose:material:material"))
            }
        }

        androidUnitTest {
            dependsOn(commonTest)
            dependencies {
                implementation(libs.truth)
            }
        }
    }
}

androidx {
    name = "Compose Internal Test Utils"
    type = LibraryType.INTERNAL_TEST_LIBRARY
    inceptionYear = "2020"
    description = "Compose internal test utils."
}

android {
    compileSdk = 35
    namespace = "androidx.compose.testutils"
}
