/*
 * Copyright (C) 2021 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.
 */


import androidx.build.KotlinTarget
import androidx.build.PlatformIdentifier
import androidx.build.LibraryType
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType

plugins {
    id("AndroidXPlugin")
    id("com.google.devtools.ksp")
    id("com.android.library")
}

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

    defaultPlatform(PlatformIdentifier.ANDROID)

    sourceSets {
        commonMain {
            dependencies {
                api(libs.kotlinStdlib)
                api("androidx.paging:paging-common:3.3.2")
                api(project(":room:room-runtime"))
                implementation(libs.atomicFu)
            }
        }

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

        androidMain {
            dependsOn(commonMain)
        }

        jvmNativeMain {
            dependsOn(commonMain)
        }

        jvmMain {
            dependsOn(jvmNativeMain)
        }

        nativeMain {
            dependsOn(jvmNativeMain)
        }

        androidInstrumentedTest {
            dependsOn(commonTest)
            dependencies {
                implementation(libs.junit)
                implementation(project(":internal-testutils-common"))
                implementation(libs.kotlinTestJunit)
                implementation(libs.testExtJunit)
                implementation(libs.testCore)
                implementation(libs.testRunner)
                implementation("androidx.arch.core:core-testing:2.2.0")
                implementation("androidx.paging:paging-testing:3.3.2")
            }
        }
        targets.configureEach { target ->
            if (target.platformType == KotlinPlatformType.native) {
                target.compilations["main"].defaultSourceSet {
                    dependsOn(nativeMain)
                }
            }
        }
    }
}

android {
    namespace = "androidx.room.paging"
}

dependencies {
    add("kspAndroidAndroidTest", project(":room:room-compiler"))
}

androidx {
    name = "Room Paging"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2021"
    description = "Room Paging integration"
    kotlinTarget = KotlinTarget.KOTLIN_2_0
}

ksp {
    useKsp2 = true
}
