/*
 * 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 {
  jvm()
  android()

  defaultPlatform(PlatformIdentifier.JVM)

  sourceSets {
    commonMain {
      dependencies {
        api(libs.kotlinStdlib)

        implementation("androidx.annotation:annotation:1.8.0")
      }
    }

    jvmAndroidMain {
      dependsOn(commonMain)
      dependencies {
        implementation(project(":ink:ink-nativeloader"))
        implementation(project(":ink:ink-geometry"))
        implementation(project(":ink:ink-brush"))
      }
    }

    jvmAndroidTest {
      dependsOn(commonTest)
      dependencies {
        implementation(libs.junit)
        implementation(libs.kotlinTest)
        implementation(libs.truth)
        implementation(project(":ink:ink-geometry"))
        implementation(project(":ink:ink-brush"))
      }
    }

    jvmMain {
      dependsOn(jvmAndroidMain)
    }

    jvmTest {
      // TODO: b/362697089 - add `dependsOn(jvmAndroidTest)` to run the tests
      //   in a JVM environment in addition to on Android emulators, once the
      //   mysterious SIGSEGV is resolved.
    }

    androidMain {
      dependsOn(jvmAndroidMain)
    }

    androidInstrumentedTest {
      dependsOn(jvmAndroidTest)
      dependencies {
        implementation(libs.testExtJunit)
        implementation(libs.testRules)
        implementation(libs.testRunner)
        implementation(libs.espressoCore)
        implementation(libs.junit)
        implementation(libs.truth)
      }
    }
  }
}

android {
  namespace = "androidx.ink.strokes"
}

androidx {
    name = "Ink Strokes"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2024"
    description = "Create beautiful strokes"
}
