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

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

androidXMultiplatform {
    android()

    defaultPlatform(PlatformIdentifier.ANDROID)

    sourceSets {
        androidMain {
            dependencies {
                implementation("androidx.collection:collection:1.4.3")
                implementation("androidx.core:core:1.1.0")
                implementation("androidx.core:core-ktx:1.12.0")
                implementation(project(":ink:ink-nativeloader"))
                implementation(project(":ink:ink-geometry"))
                implementation(project(":ink:ink-brush"))
                implementation(project(":ink:ink-strokes"))
            }
        }

        androidInstrumentedTest {
            dependencies {
                implementation(libs.testExtJunit)
                implementation(libs.testRules)
                implementation(libs.testRunner)
                implementation(libs.espressoCore)
                implementation(libs.junit)
                implementation(libs.truth)
                implementation(project(":core:core-ktx"))
                implementation(project(":test:screenshot:screenshot"))
            }
        }
    }
}

android {
    namespace = "androidx.ink.rendering"
    compileSdk = 35
}

androidx {
    name = "Ink Rendering"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2024"
    description = "Display beautiful strokes"
    addGoldenImageAssets()
}
