[Gradle, Wasm] Not add target listeners for wasi projects

^KT-66373 fixed
This commit is contained in:
Ilya Goncharov
2024-03-06 18:23:41 +00:00
committed by Space Team
parent 0bb6359ac5
commit 6fb6f04509
9 changed files with 110 additions and 7 deletions
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle
import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution
import org.jetbrains.kotlin.gradle.testbase.*
import org.jetbrains.kotlin.gradle.util.modify
import org.junit.jupiter.api.DisplayName
import java.nio.file.Files
import kotlin.io.path.writeText
@@ -186,4 +185,18 @@ class KotlinWasmGradlePluginIT : KGPBaseTest() {
}
}
}
@DisplayName("Check mix project with wasi only dependency works correctly")
@GradleTest
fun jsAndWasiTargetsWithDependencyOnWasiOnlyProject(gradleVersion: GradleVersion) {
project("wasm-wasi-js-with-wasi-only-dependency", gradleVersion) {
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
build("build") {
assertTasksExecuted(":lib:compileKotlinWasmWasi")
assertTasksExecuted(":app:compileProductionExecutableKotlinWasmJs")
assertTasksExecuted(":app:compileProductionExecutableKotlinWasmWasi")
}
}
}
}
@@ -0,0 +1,29 @@
plugins {
kotlin("multiplatform")
}
kotlin {
wasmWasi {
binaries.executable()
nodejs {}
}
wasmJs {
binaries.executable()
nodejs {}
}
sourceSets {
wasmJsMain {
dependencies {
}
}
wasmWasiMain {
dependencies {
implementation(project(":lib"))
}
}
}
}
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
class B {
}
@@ -0,0 +1,31 @@
plugins {
kotlin("multiplatform").version("<pluginMarkerVersion>").apply(false)
}
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "20.2.0"
tasks.named<org.jetbrains.kotlin.gradle.targets.js.npm.LockCopyTask>("kotlinStorePackageLock") {
//A little hacky way to make yarn results
inputFile.fileValue(projectDir.resolve("packageLockStub"))
}
}
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.d8.D8RootPlugin> {
// Test that we can set the version and it is a String.
// But use the default version since update this place every time anyway.
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.d8.D8RootExtension>().version = (version as String)
}
allprojects.forEach {
it.tasks.withType<org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
@@ -0,0 +1,10 @@
plugins {
kotlin("multiplatform")
}
kotlin {
wasmWasi {
nodejs {}
}
}
@@ -0,0 +1,6 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
class A
@@ -0,0 +1,4 @@
rootProject.name = "kotlin-wasm"
include("lib")
include("app")