[stdlib-mpp] Specify configuration attributes for stdlib-js variant disambiguation

#KT-56106
This commit is contained in:
Ilya Gorbunov
2023-03-21 23:00:22 +01:00
committed by Space Team
parent be0bf91961
commit dcc71e77f3
4 changed files with 21 additions and 1 deletions
+3
View File
@@ -4,6 +4,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
import org.jetbrains.kotlin.ideaExt.idea
import org.apache.tools.ant.filters.FixCrLfFilter
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
import java.util.Properties
plugins {
@@ -24,8 +25,10 @@ node {
val antLauncherJar by configurations.creating
val testJsRuntime by configurations.creating {
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_RUNTIME))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.legacy)
}
}
@@ -1,6 +1,7 @@
import com.github.gradle.node.npm.task.NpmTask
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink
import java.io.FileOutputStream
@@ -47,8 +48,10 @@ kotlin {
val nodeModules by configurations.registering {
extendsFrom(configurations["api"])
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, KotlinUsages.KOTLIN_RUNTIME))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_RUNTIME))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir)
}
}
+5
View File
@@ -5,6 +5,11 @@ apply plugin: 'kotlin-platform-js'
configurations {
distJs
distLibrary
[compileClasspath, testCompileClasspath, testRuntimeClasspath].forEach {
it.attributes {
attribute(org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute.jsCompilerAttribute, org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute.legacy)
}
}
}
dependencies {
+9
View File
@@ -1,5 +1,6 @@
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
plugins {
id "com.github.node-gradle.node" version "5.0.0"
@@ -13,8 +14,15 @@ configurations {
nodeModules {
extendsFrom api
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, KotlinUsages.KOTLIN_RUNTIME))
attribute(KotlinPlatformType.attribute, KotlinPlatformType.js)
attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.legacy)
}
}
[compileClasspath, testCompileClasspath, testRuntimeClasspath].forEach {
it.attributes {
attribute(org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute.jsCompilerAttribute, org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute.legacy)
}
}
}
@@ -39,6 +47,7 @@ tasks.register("populateNodeModules", Copy) {
dependsOn(compileKotlin2Js)
dependsOn(configurations.nodeModules)
from compileKotlin2Js.destinationDirectory
duplicatesStrategy = DuplicatesStrategy.EXCLUDE // temporary until stdlib mpp migration is completed
from {
configurations.nodeModules.collect {