/*
 * Copyright (C) 2022 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.LibraryType
import androidx.build.PlatformIdentifier

plugins {
    id("AndroidXPlugin")
}

androidXMultiplatform {
    androidLibrary {
        namespace = "androidx.graphics.shapes"
        withAndroidTestOnDeviceBuilder {
            it.compilationName = "instrumentedTest"
            it.defaultSourceSetName = "androidInstrumentedTest"
            it.sourceSetTreeName = "test"
        }
        withAndroidTestOnJvmBuilder {
            it.defaultSourceSetName = "androidUnitTest"
        }
    }
    desktop()
    linux()
    ios()
    watchos()
    tvos()
    mac()

    defaultPlatform(PlatformIdentifier.ANDROID)

    sourceSets {
        commonMain {
            dependencies {
                implementation(libs.kotlinStdlib)
                implementation("androidx.collection:collection:1.4.5")
                implementation("androidx.annotation:annotation:1.9.1")
            }
        }

        commonTest {
            dependencies {
            }
        }

        jvmMain {
            dependsOn(commonMain)
            dependencies {
            }
        }

        androidMain {
            dependsOn(jvmMain)
            dependencies {
                implementation("androidx.core:core-ktx:1.10.0")
                implementation("androidx.annotation:annotation-experimental:1.4.1")
            }
        }

        desktopMain {
            dependsOn(jvmMain)
        }

        nativeMain {
            dependsOn(commonMain)
        }

        androidInstrumentedTest {
            dependsOn(commonTest)
            dependencies {
                implementation(libs.testRules)
                implementation(libs.testRunner)
                implementation(libs.junit)
                implementation(libs.truth)
                implementation(libs.dexmakerMockitoInlineExtended)
                implementation(libs.mockitoKotlin)
            }
        }

        targets.configureEach { target ->
            if (target.platformType == org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.native) {
                target.compilations["main"].defaultSourceSet {
                    dependsOn(nativeMain)
                }
            }
        }
    }

    enableBinaryCompatibilityValidator = false
}


androidx {
    name = "Graphics Shapes"
    type = LibraryType.PUBLISHED_LIBRARY
    mavenVersion = LibraryVersions.GRAPHICS_SHAPES
    inceptionYear = "2022"
    description = "create and render rounded polygonal shapes"
    legacyDisableKotlinStrictApiMode = true
    metalavaK2UastEnabled = false
    kotlinTarget = KotlinTarget.KOTLIN_1_9
}
