| import androidx.build.KmpPlatformsKt |
| import androidx.build.LibraryType |
| import androidx.build.Publish |
| import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType |
| import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile |
| |
| plugins { |
| id("AndroidXPlugin") |
| } |
| |
| androidXMultiplatform { |
| jvm { |
| withJava() // Remove after b/247980072 |
| } |
| mac() |
| linux() |
| ios() |
| |
| sourceSets { |
| commonMain { |
| dependencies { |
| api(libs.kotlinStdlib) |
| } |
| } |
| |
| if (KmpPlatformsKt.enableNative(project)) { |
| nonJvmMain { |
| dependsOn commonMain |
| } |
| |
| targets.all { 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 { |
| from sourceSets.main.output |
| // 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 = "Android Support Library Annotations" |
| type = LibraryType.PUBLISHED_LIBRARY |
| mavenVersion = LibraryVersions.ANNOTATION |
| mavenGroup = LibraryGroups.ANNOTATION |
| inceptionYear = "2013" |
| description = "The Support Library is a static library that you can add to your Android application in order to use APIs that are either not available for older platform versions or utility APIs that aren't a part of the framework APIs." |
| } |