/**
 * 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.LibraryType
import androidx.build.PlatformIdentifier
import androidx.build.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile

plugins {
    id("AndroidXPlugin")
}

androidXMultiplatform {
    androidNative()
    ios()
    js()
    jvm()
    linux()
    mac()
    mingwX64()
    tvos()
    wasmJs()
    watchos()

    defaultPlatform(PlatformIdentifier.JVM)

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

        nonJvmMain {
            dependsOn(commonMain)
        }

        wasmJsMain {
            dependsOn(nonJvmMain)
        }

        jsMain {
            dependsOn(nonJvmMain)
        }

        targets.configureEach { target ->
            if (target.platformType !in [KotlinPlatformType.jvm, KotlinPlatformType.common]) {
                target.compilations["main"].defaultSourceSet {
                    dependsOn(nonJvmMain)
                }
            }
        }

        // Workaround for https://youtrack.jetbrains.com/issue/KT-51763
        // Make sure commonization runs before any compilation task.
        tasks.withType(KotlinNativeCompile).configureEach {
            it.dependsOn(tasks.named("commonize"))
        }
    }
}

jvmJar {
    // Strip out typedef classes. For Android libraries, this is done
    // automatically by the Gradle plugin, but the Annotation library is a
    // plain jar, built by the regular Gradle java plugin. The typedefs
    // themselves have been manually extracted into the
    // external-annotations directory, and those are packaged separately
    // below by the annotationsZip task.
    exclude("androidx/annotation/ProductionVisibility.class")
    exclude("androidx/annotation/DimensionUnit.class")
}

task annotationsZip(type: Zip) {
    archiveClassifier.set("annotations")
    from("external-annotations")
}

// add annotations jar task as artifacts
artifacts {
    archives jvmJar
    archives annotationsZip
}

androidx {
    name = "Annotation"
    type = LibraryType.PUBLISHED_LIBRARY
    mavenVersion = LibraryVersions.ANNOTATION
    kotlinTarget = KotlinTarget.KOTLIN_1_9
    inceptionYear = "2013"
    description = "Provides source annotations for tooling and readability."
}
