/*
 * 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.
 */


import androidx.build.AndroidXUiPlugin
import androidx.build.LibraryGroups
import androidx.build.LibraryType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

import static androidx.build.dependencies.DependenciesKt.*

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

AndroidXUiPlugin.applyAndConfigureKotlinPlugin(project)

if(!AndroidXUiPlugin.isMultiplatformEnabled(project)) {
    dependencies {
        /*
         * When updating dependencies, make sure to make the an an analogous update in the
         * corresponding block below
         */
        implementation(KOTLIN_STDLIB_COMMON)

        api(project(":compose:ui:ui-graphics"))
        api(project(":compose:ui:ui-unit"))
        api("androidx.annotation:annotation:1.1.0")

        implementation(project(":compose:runtime:runtime"))
        implementation(project(":compose:runtime:runtime-saveable"))
        implementation(project(":compose:ui:ui-util"))
        implementation(KOTLIN_STDLIB)
        implementation("androidx.collection:collection:1.1.0")
        implementation("androidx.core:core:1.5.0-rc02")

        testImplementation(project(":compose:ui:ui-test-font"))
        testImplementation(ANDROIDX_TEST_RULES)
        testImplementation(ANDROIDX_TEST_RUNNER)
        testImplementation(JUNIT)
        testImplementation(MOCKITO_CORE)
        testImplementation(TRUTH)
        testImplementation(KOTLIN_REFLECT)
        testImplementation(MOCKITO_KOTLIN, {
            exclude group: "org.mockito" // to keep control on the mockito version
        })

        androidTestImplementation(project(":compose:ui:ui-test-font"))
        androidTestImplementation(project(":compose:ui:ui-test-junit4"))
        androidTestImplementation(ANDROIDX_TEST_RULES)
        androidTestImplementation(ANDROIDX_TEST_RUNNER)
        androidTestImplementation(ESPRESSO_CORE)
        androidTestImplementation(JUNIT)
        androidTestImplementation(DEXMAKER_MOCKITO, excludes.bytebuddy)
        // DexMaker has it"s own MockMaker
        androidTestImplementation(MOCKITO_CORE, excludes.bytebuddy)
        androidTestImplementation(TRUTH)
        androidTestImplementation(MOCKITO_KOTLIN, {
            exclude group: "org.mockito" // to keep control on the mockito version
        })
    }

    android {
        sourceSets {
            main {
                java.srcDirs += "../../../text/text/src/main/java"
            }
        }
    }
}

if(AndroidXUiPlugin.isMultiplatformEnabled(project)) {
    kotlin {
        android()
        jvm("desktop")

        /*
         * When updating dependencies, make sure to make the an an analogous update in the
         * corresponding block below
         */
        sourceSets {
            commonMain.dependencies {
                implementation(KOTLIN_STDLIB_COMMON)

                api(project(":compose:ui:ui-graphics"))
                api(project(":compose:ui:ui-unit"))

                implementation(project(":compose:runtime:runtime"))
                implementation(project(":compose:runtime:runtime-saveable"))
                implementation(project(":compose:ui:ui-util"))
            }

            jvmMain.dependencies {
                implementation(KOTLIN_STDLIB)
            }

            desktopMain.dependsOn(jvmMain)
            androidMain.dependsOn(jvmMain)

            androidMain.dependencies {
                api("androidx.annotation:annotation:1.1.0")
                implementation("androidx.collection:collection:1.1.0")
                implementation("androidx.core:core:1.5.0-rc02")
            }

            androidMain.kotlin.srcDirs("../../../text/text/src/main/java")

            androidTest.dependencies {
                implementation(project(":compose:ui:ui-test-font"))
                implementation(ANDROIDX_TEST_RULES)
                implementation(ANDROIDX_TEST_RUNNER)
                implementation(JUNIT)
                implementation(MOCKITO_CORE)
                implementation(TRUTH)
                implementation(KOTLIN_REFLECT)
                implementation(MOCKITO_KOTLIN, {
                    exclude group: "org.mockito" // to keep control on the mockito version
                })
            }

            androidAndroidTest.dependencies {
                implementation(project(":compose:ui:ui-test-junit4"))
                implementation(project(":compose:ui:ui-test-font"))
                implementation(ANDROIDX_TEST_RULES)
                implementation(ANDROIDX_TEST_RUNNER)
                implementation(ESPRESSO_CORE)
                implementation(JUNIT)
                implementation(DEXMAKER_MOCKITO, excludes.bytebuddy)
                // DexMaker has it"s own MockMaker
                implementation(MOCKITO_CORE, excludes.bytebuddy)
                implementation(TRUTH)
                implementation(MOCKITO_KOTLIN, {
                    exclude group: "org.mockito" // to keep control on the mockito version
                })
            }

            desktopTest.dependencies {
                implementation(TRUTH)
                implementation(JUNIT)
                implementation(SKIKO_CURRENT_OS)
                implementation(project(":compose:foundation:foundation"))
                implementation(project(":compose:ui:ui-test-junit4"))
                implementation(project(":compose:ui:ui-test-font"))
            }
        }
    }
}

androidx {
    name = "Compose UI Text"
    type = LibraryType.PUBLISHED_LIBRARY
    mavenGroup = LibraryGroups.Compose.UI
    inceptionYear = "2019"
    description = "Compose Text primitives and utilities"
    legacyDisableKotlinStrictApiMode = true
}

tasks.withType(KotlinCompile).configureEach {
    kotlinOptions {
        freeCompilerArgs += ["-XXLanguage:+InlineClasses"]
    }
}
