import com.android.build.api.dsl.AaptOptions
import com.android.build.api.dsl.AndroidResources
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.compose.ExperimentalComposeLibrary
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree

mavenPublishing {
    publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
    coordinates("com.performancecoachlab.posedetection", "posedetection-compose", "4.4.0")

    pom {
        name.set("Pose Detection")
        description.set("real time body tracking for compose multiplatform mobile apps")
        inceptionYear.set("2025")
        url.set("https://tangled.sh/@nateholland.bsky.social/PoseDetection")
        licenses {
            license {
                name.set("The Apache License, Version 2.0")
                url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
                distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
            }
        }
        developers {
            developer {
                id.set("nateholland")
                name.set("Nate")
                url.set("https://tangled.sh/@nateholland.bsky.social")
            }
        }
        scm {
            url.set("https://tangled.sh/@nateholland.bsky.social/PoseDetection")
            connection.set("scm:git:git://tangled.sh/@nateholland.bsky.social/PoseDetection.git")
            developerConnection.set("scm:git:ssh://git@tangled.sh:nateholland.bsky.social/PoseDetection")
        }
    }
    signAllPublications()
}
plugins {
    alias(libs.plugins.multiplatform)
    alias(libs.plugins.compose.compiler)
    alias(libs.plugins.compose)
    alias(libs.plugins.android.library)
    id("com.vanniktech.maven.publish") version "0.31.0"
}

kotlin {
    jvmToolchain(11)
    androidTarget {
        //https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-test.html
        instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
    }

    listOf(
        iosX64(),
        iosArm64(),
        iosSimulatorArm64()
    ).forEach {
        it.binaries.framework {
            baseName = "ComposeApp"
            isStatic = true
        }
    }

    sourceSets {
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material3)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            api("co.touchlab:kermit:2.0.4")
        }

        commonTest.dependencies {
            implementation(kotlin("test"))
            @OptIn(ExperimentalComposeLibrary::class)
            implementation(compose.uiTest)
        }

        androidMain.dependencies {
            implementation(compose.uiTooling)
            implementation(libs.androidx.activityCompose)
            implementation(libs.androidx.camera.core)
            implementation(libs.androidx.camera.camera2)
            implementation(libs.androidx.camera.lifecycle)
            implementation(libs.androidx.camera.video)
            implementation(libs.androidx.camera.view)
            implementation(libs.androidx.camera.extensions)
            implementation(libs.androidx.camera.compose)
            implementation(libs.pose.detection)
            implementation(libs.pose.detection.common)
            implementation(libs.androidx.media3.common.ktx)
            implementation(libs.tensorflow.lite.task.vision)
        }

    }
}

android {
    namespace = "com.performancecoachlab.posedetection"
    compileSdk = 35
    defaultConfig {
        minSdk = 21
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }
    buildFeatures {
        mlModelBinding = true
    }
}

//https://developer.android.com/develop/ui/compose/testing#setup
dependencies {
    androidTestImplementation(libs.androidx.uitest.junit4)
    debugImplementation(libs.androidx.uitest.testManifest)
}
