/*
 * Copyright (C) 2016 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.SoftwareType
import androidx.build.PlatformIdentifier
import com.android.build.api.dsl.KotlinMultiplatformAndroidHostTestCompilation
import com.android.build.gradle.internal.lint.AndroidLintAnalysisTask
import com.android.build.gradle.internal.lint.LintModelWriterTask
import com.google.devtools.ksp.gradle.KspAATask
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.konan.target.Family

plugins {
    id("AndroidXPlugin")
    id("androidx.stableaidl")
    id("com.google.devtools.ksp")
}

configurations {
    // Configuration for resolving shared archive file of androidx's SQLite compilation
    sqliteSharedArchive {
        canBeConsumed = false
        canBeResolved = true
        attributes {
            attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.NATIVE_LINK))
        }
    }
}


androidXMultiplatform {
    androidLibrary {
        withJava()
        namespace = "androidx.room"
        optimization {
            it.consumerKeepRules.publish = true
            it.consumerKeepRules.files.add(
                    new File(project.projectDir, "src/androidMain/proguard-rules.pro")
            )
        }
        stableAidl {
            version = 1
        }
        compilations.withType(KotlinMultiplatformAndroidHostTestCompilation) {
            it.returnDefaultValues = true
        }

        // Needed for api tasks and docs generation
        sourceSets {
            androidMain {
                kotlin.srcDirs += 'src/androidMain/java'
            }
        }
    }
    ios() {
        // Link to sqlite3 available in iOS
        binaries.configureEach {
            linkerOpts += ["-lsqlite3"]
        }
    }
    jvm()
    linux()
    mac()
    tvos()
    watchos()

    defaultPlatform(PlatformIdentifier.ANDROID)

    // Source set structure:
    //                            ┌──────────────────┐
    //                            │    commonMain    │
    //                            └──────────────────┘
    //                                      │
    //                       ┌──────────────┴─────────────┐
    //                       │                            │
    //                       ▼                            ▼
    //             ┌──────────────────┐         ┌──────────────────┐
    //             │  jvmAndroidMain  │         │  jvmNativeMain   │
    //             └──────────────────┘         └──────────────────┘
    //                       │                            │
    //           ┌───────────┴──────────────┬─────────────┴───────────┐
    //           │                          │                         │
    //           ▼                          ▼                         ▼
    // ┌──────────────────┐       ┌──────────────────┐      ┌──────────────────┐
    // │   androidMain    │       │     jvmMain      │      │    nativeMain    │
    // └──────────────────┘       └──────────────────┘      └──────────────────┘
    sourceSets {
        commonMain {
            dependencies {
                api(libs.kotlinStdlib)
                api(project(":room:room-common"))
                api(project(":sqlite:sqlite"))
                api("androidx.collection:collection:1.5.0")
                api("androidx.annotation:annotation:1.9.1")
                api(libs.kotlinCoroutinesCore)
            }
        }
        commonTest {
            dependencies {
                implementation(libs.kotlinTest)
                implementation(libs.kotlinCoroutinesTest)
                implementation(project(":kruth:kruth"))
            }
        }
        jvmAndroidMain {
            dependsOn(commonMain)
        }
        jvmNativeMain {
            dependsOn(commonMain)
        }
        jvmMain {
            dependsOn(jvmAndroidMain)
            dependsOn(jvmNativeMain)
        }
        jvmTest {
            dependsOn(commonTest)
            dependencies {
                implementation(project(":sqlite:sqlite-bundled"))
                implementation(libs.kotlinTestJunit)
            }
        }
        androidMain {
            dependsOn(jvmAndroidMain)
            dependencies {
                api(libs.jspecify)
                api(project(":sqlite:sqlite-framework"))
                api(libs.kotlinCoroutinesAndroid)
                implementation("androidx.arch.core:core-runtime:2.2.0")
                compileOnly("androidx.lifecycle:lifecycle-livedata-core:2.0.0")
                compileOnly("androidx.paging:paging-common:2.0.0")
                implementation("androidx.annotation:annotation-experimental:1.5.0")
            }
        }
        androidUnitTest {
            dependsOn(commonTest)
            dependencies {
                implementation("androidx.arch.core:core-testing:2.2.0")
                implementation(libs.junit)
                implementation(libs.byteBuddy)
                implementation(libs.mockitoCore4)
                implementation(libs.mockitoKotlin4)
                implementation("androidx.lifecycle:lifecycle-livedata-core:2.0.0")
                implementation(libs.testRunner) // Needed for @FlakyTest and @Ignore
            }
        }
        androidInstrumentedTest {
            dependsOn(commonTest)
            dependencies {
                implementation(project(":sqlite:sqlite-bundled"))
                implementation(libs.junit)
                implementation(libs.testExtJunit)
                implementation(libs.testCore)
                implementation(libs.testRunner)
                implementation(libs.espressoCore)
                implementation(libs.mockitoCore)
                implementation(libs.dexmakerMockito)
                implementation(project(":internal-testutils-truth")) // for assertThrows
                implementation(project(":kruth:kruth"))
                implementation("androidx.arch.core:core-testing:2.2.0")
            }
        }
        nativeMain {
            dependsOn(jvmNativeMain)
            dependencies {
                api(project(":sqlite:sqlite-framework"))
                implementation(libs.atomicFu)
            }
        }
        nativeTest {
            dependsOn(commonTest)
            dependencies {
                implementation(project(":sqlite:sqlite-bundled"))
                implementation(libs.okio)
            }
        }
        targets.configureEach { target ->
            if (target.platformType == KotlinPlatformType.native) {
                target.compilations["main"].defaultSourceSet {
                    dependsOn(nativeMain)
                }
                def test = target.compilations["test"]
                test.defaultSourceSet {
                    dependsOn(nativeTest)
                }
                if (target.konanTarget.family == Family.LINUX) {
                    // For tests in Linux host, statically include androidx's compiled SQLite
                    // via a generated C interop definition
                    createCinteropFromArchiveConfiguration(test, configurations["sqliteSharedArchive"])
                } else if (target.konanTarget.family == Family.OSX) {
                    // For tests in Mac host, link to shared SQLite library included in MacOS
                    test.kotlinOptions.freeCompilerArgs += [
                            "-linker-options", "-lsqlite3"
                    ]
                }
            }
        }
    }
}

dependencies {
    lintChecks(project(":room:room-runtime-lint"))
    sqliteSharedArchive(project(":sqlite:sqlite-bundled"))
    add("kspAndroidInstrumentedTest", project(":room:room-compiler"))
}

androidx {
    name = "Room-Runtime"
    type = SoftwareType.PUBLISHED_LIBRARY
    inceptionYear = "2017"
    description = "Android Room-Runtime"
    kotlinTarget = KotlinTarget.KOTLIN_2_1
}

// TODO(https://github.com/google/ksp/issues/2250) Remove when KSP migrates to the new variants API
// Without this, dependency introduced between lintAnalyzeAndroidInstrumentedTest and kspAndroidInstrumentedTest
tasks.withType(AndroidLintAnalysisTask).configureEach {
    mustRunAfter(tasks.withType(KspAATask))
}

// TODO(https://github.com/google/ksp/issues/2250) Remove when KSP migrates to the new variants API
// Without this, dependency introduced between lintAnalyzeAndroidInstrumentedTest and kspAndroidInstrumentedTest
tasks.withType(LintModelWriterTask).configureEach {
    mustRunAfter(tasks.withType(KspAATask))
}
