/*
 * Copyright (C) 2017 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.PlatformIdentifier
import androidx.build.LibraryType
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType

plugins {
    id("AndroidXPlugin")
}

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

    defaultPlatform(PlatformIdentifier.ANDROID)

    sourceSets {
        commonMain {
            dependencies {
                api(libs.kotlinStdlib)
                api(project(":room:room-common"))
                api(project(":room:room-runtime"))
                api(project(":sqlite:sqlite"))
                implementation(project(":room:room-migration"))
            }
        }
        commonTest {
            dependencies {
                implementation(libs.kotlinTest)
                implementation(project(":kruth:kruth"))
            }
        }
        jvmMain {
            dependsOn(commonMain)
            dependencies {
                api(libs.junit)
            }
        }
        androidMain {
            dependsOn(commonMain)
            dependencies {
                api(libs.junit)
                api(project(":sqlite:sqlite-framework"))
                implementation("androidx.arch.core:core-runtime:2.2.0")
            }
        }
        nativeMain {
            dependsOn(commonMain)
            dependencies {
                implementation(libs.okio)
            }
        }
        targets.configureEach { target ->
            if (target.platformType == KotlinPlatformType.native) {
                target.compilations["main"].defaultSourceSet {
                    dependsOn(nativeMain)
                }
            }
        }
    }
}


androidx {
    name = "Room Testing"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2017"
    description = "Android Room Testing"
    legacyDisableKotlinStrictApiMode = true
    metalavaK2UastEnabled = false
    kotlinTarget = KotlinTarget.KOTLIN_2_0
}
