From 7794998113a0fe2908641628b4ca93c3fde83244 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Tue, 14 Mar 2023 12:34:19 +0000 Subject: [PATCH] [Gradle, JS] Use JAR archive task type for js ir --- .../kotlin/gradle/NewMultiplatformIT.kt | 10 ++++++ .../mpp-empty-sources/build.gradle.kts | 35 +++++++++++++++++++ .../js/ir/KotlinJsIrTargetConfigurator.kt | 3 +- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-empty-sources/build.gradle.kts diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt index 4c134d950d238..fc1c4f2fc9a7c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt @@ -2045,6 +2045,16 @@ open class NewMultiplatformIT : BaseGradleIT() { } } + @Test + fun testPublishEmptySourceSets() = with(Project("mpp-empty-sources")) { + setupWorkingDir() + gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl) + + build("publish") { + assertSuccessful() + } + } + private fun detectNativeEnabledCompilation(): String = when { HostManager.hostIsLinux -> "linuxX64" HostManager.hostIsMingw -> "mingwX64" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-empty-sources/build.gradle.kts b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-empty-sources/build.gradle.kts new file mode 100644 index 0000000000000..cdce99dfc556f --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/mpp-empty-sources/build.gradle.kts @@ -0,0 +1,35 @@ +plugins { + kotlin("multiplatform") version "" + `maven-publish` +} + +group = "org.example" +version = "1.0-SNAPSHOT" + +repositories { + mavenCentral() + mavenLocal() +} + +kotlin { + jvm { + jvmToolchain(8) + withJava() + } + js(IR) { + binaries.executable() + browser { + } + } +} + +publishing { + publications { + create("maven") { + from(components["kotlin"]) + } + } + repositories { + maven { setUrl("${rootProject.buildDir}/repo") } + } +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetConfigurator.kt index e3b0843994323..3b6258fa66fcb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/ir/KotlinJsIrTargetConfigurator.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle.targets.js.ir import org.gradle.api.attributes.Usage import org.gradle.api.tasks.TaskProvider +import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.bundling.Zip import org.jetbrains.kotlin.gradle.dsl.JsModuleKind import org.jetbrains.kotlin.gradle.dsl.JsSourceMapEmbedMode @@ -32,7 +33,7 @@ open class KotlinJsIrTargetConfigurator : get() = KLIB_TYPE override val archiveTaskType: Class - get() = Zip::class.java + get() = Jar::class.java override fun createTestRun( name: String,