[stdlib-mpp] Publish wasm artifacts through variants of stdlib KT-60909
This commit is contained in:
committed by
Space Team
parent
73b4a81663
commit
9640e32483
@@ -325,8 +325,6 @@ extra["compilerArtifactsForIde"] = listOfNotNull(
|
||||
":plugins:parcelize:parcelize-runtime",
|
||||
":kotlin-stdlib-common",
|
||||
":kotlin-stdlib",
|
||||
":kotlin-stdlib-wasm-js",
|
||||
":kotlin-stdlib-wasm-wasi",
|
||||
":kotlin-test",
|
||||
":kotlin-daemon",
|
||||
":kotlin-compiler",
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.gradle.jvm.tasks.Jar
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinWasmTargetAttribute
|
||||
import org.jetbrains.kotlin.gradle.tasks.UsesKotlinJavaToolchain
|
||||
import plugins.configureDefaultPublishing
|
||||
import plugins.configureKotlinPomAttributes
|
||||
@@ -23,9 +24,20 @@ description = "Kotlin Standard Library"
|
||||
|
||||
configureJvmToolchain(JdkMajorVersion.JDK_1_8)
|
||||
|
||||
val configurationBuiltins = configurations.create("builtins") {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
fun resolvingConfiguration(name: String, configure: Action<Configuration> = Action {}) =
|
||||
configurations.create(name) {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
configure(this)
|
||||
}
|
||||
fun outgoingConfiguration(name: String, configure: Action<Configuration> = Action {}) =
|
||||
configurations.create(name) {
|
||||
isCanBeResolved = false
|
||||
isCanBeConsumed = true
|
||||
configure(this)
|
||||
}
|
||||
|
||||
val configurationBuiltins = resolvingConfiguration("builtins") {
|
||||
attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.JAR))
|
||||
}
|
||||
dependencies {
|
||||
@@ -776,6 +788,49 @@ tasks {
|
||||
|
||||
}
|
||||
|
||||
// republishing artifacts from kotlin-stdlib-wasm-* projects
|
||||
// TODO: replace with wasm targets compilation in this project
|
||||
fun wasmOutgoingConfigurations(target: KotlinWasmTargetAttribute) {
|
||||
val targetName = target.toString().replaceFirstChar { it.uppercase() }
|
||||
val klib = resolvingConfiguration("wasm${targetName}Klib")
|
||||
val sources = resolvingConfiguration("wasm${targetName}Sources")
|
||||
dependencies {
|
||||
klib(project(":kotlin-stdlib-wasm-$target", configuration = "wasmRuntimeElements"))
|
||||
sources(project(":kotlin-stdlib-wasm-$target", configuration = "wasmSourcesElements"))
|
||||
}
|
||||
listOf(KotlinUsages.KOTLIN_API, KotlinUsages.KOTLIN_RUNTIME).map { usage ->
|
||||
val name = usage.substringAfter("kotlin-")
|
||||
val configuration = outgoingConfiguration("wasm${targetName}${name.replaceFirstChar { it.uppercase() }}Elements") {
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
|
||||
attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named("non-jvm"))
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(usage))
|
||||
attribute(KotlinPlatformType.attribute, KotlinPlatformType.wasm)
|
||||
attribute(KotlinWasmTargetAttribute.wasmTargetAttribute, target)
|
||||
}
|
||||
}
|
||||
artifacts.add(configuration.name, provider { klib.singleFile }) {
|
||||
builtBy(klib)
|
||||
}
|
||||
}
|
||||
val outSources = outgoingConfiguration("wasm${targetName}SourcesElements") {
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
|
||||
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES))
|
||||
attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named("non-jvm"))
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_RUNTIME))
|
||||
attribute(KotlinPlatformType.attribute, KotlinPlatformType.wasm)
|
||||
attribute(KotlinWasmTargetAttribute.wasmTargetAttribute, target)
|
||||
}
|
||||
}
|
||||
artifacts.add(outSources.name, provider { sources.singleFile }) {
|
||||
builtBy(sources)
|
||||
}
|
||||
}
|
||||
|
||||
wasmOutgoingConfigurations(KotlinWasmTargetAttribute.js)
|
||||
wasmOutgoingConfigurations(KotlinWasmTargetAttribute.wasi)
|
||||
|
||||
|
||||
// region ==== Publishing ====
|
||||
|
||||
@@ -845,24 +900,6 @@ publishing {
|
||||
attribute(KotlinPlatformType.attribute, KotlinPlatformType.native)
|
||||
}
|
||||
}
|
||||
// empty variant for wasm
|
||||
// TODO: replace with wasm target
|
||||
variant("wasmApiElements") {
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
|
||||
attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named("non-jvm"))
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_API))
|
||||
attribute(KotlinPlatformType.attribute, KotlinPlatformType.wasm)
|
||||
}
|
||||
}
|
||||
variant("wasmRuntimeElements") {
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
|
||||
attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named("non-jvm"))
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_RUNTIME))
|
||||
attribute(KotlinPlatformType.attribute, KotlinPlatformType.wasm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we cannot publish legacy common artifact with metadata in kotlin-stdlib-common
|
||||
@@ -888,8 +925,27 @@ publishing {
|
||||
variant("jsSourcesElements")
|
||||
}
|
||||
|
||||
val wasmJs = module("wasmJsModule") {
|
||||
mavenPublication {
|
||||
artifactId = "$artifactBaseName-wasm-js"
|
||||
configureKotlinPomAttributes(project, "Kotlin Standard Library for experimental WebAssembly JS platform", packaging = "klib")
|
||||
}
|
||||
variant("wasmJsApiElements")
|
||||
variant("wasmJsRuntimeElements")
|
||||
variant("wasmJsSourcesElements")
|
||||
}
|
||||
val wasmWasi = module("wasmWasiModule") {
|
||||
mavenPublication {
|
||||
artifactId = "$artifactBaseName-wasm-wasi"
|
||||
configureKotlinPomAttributes(project, "Kotlin Standard Library for experimental WebAssembly WASI platform", packaging = "klib")
|
||||
}
|
||||
variant("wasmWasiApiElements")
|
||||
variant("wasmWasiRuntimeElements")
|
||||
variant("wasmWasiSourcesElements")
|
||||
}
|
||||
|
||||
// Makes all variants from accompanying artifacts visible through `available-at`
|
||||
rootModule.include(js)
|
||||
rootModule.include(js, wasmJs, wasmWasi)
|
||||
}
|
||||
|
||||
publications {
|
||||
@@ -897,6 +953,13 @@ publishing {
|
||||
val jsModule by existing(MavenPublication::class)
|
||||
configureSbom("Main", "kotlin-stdlib", setOf("jvmRuntimeClasspath"), rootModule)
|
||||
configureSbom("Js", "kotlin-stdlib-js", setOf("jsRuntimeClasspath"), jsModule)
|
||||
|
||||
val wasmJsModule by existing(MavenPublication::class)
|
||||
val wasmWasiModule by existing(MavenPublication::class)
|
||||
// an arbitrary empty classpath configuration is used for the following sboms
|
||||
// TODO: replace with classpath configurations of the corresponding target compilations when they are migrated here (though empty as well)
|
||||
configureSbom("Wasm-Js", "kotlin-stdlib-wasm-js", setOf("metadataCompileClasspath"), wasmJsModule)
|
||||
configureSbom("Wasm-Wasi", "kotlin-stdlib-wasm-wasi", setOf("metadataCompileClasspath"), wasmWasiModule)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,30 @@
|
||||
"sourceSet": [
|
||||
"commonMain"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "wasmJsApiElements",
|
||||
"sourceSet": [
|
||||
"commonMain"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "wasmJsRuntimeElements",
|
||||
"sourceSet": [
|
||||
"commonMain"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "wasmWasiApiElements",
|
||||
"sourceSet": [
|
||||
"commonMain"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "wasmWasiRuntimeElements",
|
||||
"sourceSet": [
|
||||
"commonMain"
|
||||
]
|
||||
}
|
||||
],
|
||||
"sourceSets": [
|
||||
|
||||
@@ -23,25 +23,3 @@ configureWasmStdLib(
|
||||
) { extensionBody ->
|
||||
kotlin(extensionBody)
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
// cleanup default publications
|
||||
// TODO: remove after mpp plugin allows avoiding their creation at all, KT-29273
|
||||
publishing {
|
||||
publications.removeAll { it.name != "Main" }
|
||||
}
|
||||
|
||||
tasks.withType<AbstractPublishToMaven> {
|
||||
if (publication.name != "Main") this.enabled = false
|
||||
}
|
||||
|
||||
tasks.named("publish") {
|
||||
doFirst {
|
||||
publishing.publications {
|
||||
if (singleOrNull()?.name != "Main") {
|
||||
throw GradleException("kotlin-stdlib-wasm should have only one publication, found $size: ${joinToString { it.name }}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,25 +21,3 @@ configureWasmStdLib(
|
||||
) { extensionBody ->
|
||||
kotlin(extensionBody)
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
// cleanup default publications
|
||||
// TODO: remove after mpp plugin allows avoiding their creation at all, KT-29273
|
||||
publishing {
|
||||
publications.removeAll { it.name != "Main" }
|
||||
}
|
||||
|
||||
tasks.withType<AbstractPublishToMaven> {
|
||||
if (publication.name != "Main") this.enabled = false
|
||||
}
|
||||
|
||||
tasks.named("publish") {
|
||||
doFirst {
|
||||
publishing.publications {
|
||||
if (singleOrNull()?.name != "Main") {
|
||||
throw GradleException("kotlin-stdlib-wasm should have only one publication, found $size: ${joinToString { it.name }}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<!-- This module was also published with a richer model, Gradle metadata, -->
|
||||
<!-- which should be used instead. Do not delete the following line which -->
|
||||
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
|
||||
<!-- that they should prefer consuming it instead. -->
|
||||
<!-- do_not_remove: published-with-gradle-metadata -->
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-wasm-js</artifactId>
|
||||
|
||||
+5
@@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<!-- This module was also published with a richer model, Gradle metadata, -->
|
||||
<!-- which should be used instead. Do not delete the following line which -->
|
||||
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
|
||||
<!-- that they should prefer consuming it instead. -->
|
||||
<!-- do_not_remove: published-with-gradle-metadata -->
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-wasm-wasi</artifactId>
|
||||
|
||||
@@ -64,8 +64,6 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
|
||||
":kotlin-stdlib",
|
||||
":kotlin-stdlib-jdk7",
|
||||
":kotlin-stdlib-jdk8",
|
||||
":kotlin-stdlib-wasm-js",
|
||||
":kotlin-stdlib-wasm-wasi",
|
||||
":kotlin-dom-api-compat",
|
||||
":examples:annotation-processor-example",
|
||||
":kotlin-assignment-compiler-plugin.embeddable",
|
||||
|
||||
@@ -160,19 +160,4 @@ fun Project.configureWasmStdLib(
|
||||
tasks.named("compileTestDevelopmentExecutableKotlinWasm", KotlinJsIrLink::class.java) {
|
||||
kotlinOptions.freeCompilerArgs += listOf("-Xwasm-enable-array-range-checks")
|
||||
}
|
||||
|
||||
val runtimeElements = configurations.create("runtimeElements") { }
|
||||
|
||||
configurations.create("apiElements") { }
|
||||
|
||||
publish(sbom = false) {
|
||||
pom.packaging = "klib"
|
||||
artifact(tasks.named("wasmJar")) {
|
||||
extension = "klib"
|
||||
}
|
||||
}
|
||||
|
||||
configureSbom(
|
||||
gradleConfigurations = setOf(runtimeElements.name)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user