/*
 * 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"))
      }
    }

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

    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)
	implementation("androidx.graphics:graphics-path:1.0.1")
      }
    }
  }
}

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

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