[Gradle, JS] Add test on hmpp with both js

#KT-38592 fixed
This commit is contained in:
Ilya Goncharov
2020-05-20 14:13:15 +03:00
parent a6812e5d6a
commit 79984b6e04
8 changed files with 160 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 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.
*/
@@ -7,9 +7,10 @@ package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.internals.MULTIPLATFORM_PROJECT_METADATA_FILE_NAME
import org.jetbrains.kotlin.gradle.internals.parseKotlinSourceSetMetadataFromXml
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinProjectStructureMetadata
import org.jetbrains.kotlin.gradle.plugin.mpp.SourceSetMetadataLayout
import org.jetbrains.kotlin.gradle.plugin.mpp.ModuleDependencyIdentifier
import org.jetbrains.kotlin.gradle.plugin.mpp.SourceSetMetadataLayout
import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet
import org.jetbrains.kotlin.gradle.util.checkedReplace
import org.jetbrains.kotlin.gradle.util.modify
@@ -144,8 +145,37 @@ class HierarchicalMppIT : BaseGradleIT() {
}
}
private fun publishThirdPartyLib(withGranularMetadata: Boolean): Project =
Project("third-party-lib", gradleVersion, "hierarchical-mpp-published-modules").apply {
@Test
fun testHmppWithJsBothDependency() {
val directoryPrefix = "hierarchical-mpp-with-js-modules"
publishThirdPartyLib(
projectName = "third-party-lib",
directoryPrefix = directoryPrefix,
withGranularMetadata = true,
jsCompilerType = KotlinJsCompilerType.BOTH
)
with(Project("my-lib-foo", gradleVersion, directoryPrefix)) {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
build(
"publish",
"assemble",
options = defaultBuildOptions().copy(jsCompilerType = KotlinJsCompilerType.IR)
) {
assertSuccessful()
}
}
}
private fun publishThirdPartyLib(
projectName: String = "third-party-lib",
directoryPrefix: String = "hierarchical-mpp-published-modules",
withGranularMetadata: Boolean,
jsCompilerType: KotlinJsCompilerType = KotlinJsCompilerType.LEGACY
): Project =
Project(projectName, gradleVersion, directoryPrefix).apply {
setupWorkingDir()
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
@@ -153,7 +183,10 @@ class HierarchicalMppIT : BaseGradleIT() {
projectDir.resolve("gradle.properties").appendText("kotlin.mpp.enableGranularSourceSetsMetadata=true")
}
build("publish") {
build(
"publish",
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
) {
assertSuccessful()
}
}
@@ -0,0 +1,38 @@
plugins {
kotlin("multiplatform").version("<pluginMarkerVersion>")
`maven-publish`
}
repositories {
mavenLocal()
maven("../repo")
jcenter()
}
group = "com.example.foo"
version = "1.0"
kotlin {
js()
sourceSets {
js().compilations["main"].defaultSourceSet {
dependencies {
api("com.example.thirdparty:third-party-lib:1.0")
implementation(kotlin("stdlib-js"))
}
}
js().compilations["test"].defaultSourceSet {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
publishing {
repositories {
maven("../repo")
}
}
@@ -0,0 +1,3 @@
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.disableCompilerDaemon=true
kotlin.mpp.enableCompatibilityMetadataVariant=true
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}
rootProject.name = "my-lib-foo"
enableFeaturePreview("GRADLE_METADATA")
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2020 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.
*/
package com.example.foo
import com.example.thirdparty.thirdPartyJsFun
fun fooJvmAndJs(): String {
thirdPartyJsFun()
return "hello"
}
@@ -0,0 +1,40 @@
plugins {
kotlin("js").version("<pluginMarkerVersion>")
`maven-publish`
}
repositories {
mavenLocal()
jcenter()
}
group = "com.example.thirdparty"
version = "1.0"
kotlin {
js()
sourceSets {
js().compilations["main"].defaultSourceSet {
dependencies {
implementation(kotlin("stdlib-js"))
}
}
js().compilations["test"].defaultSourceSet {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
publishing {
repositories {
maven("../repo")
}
publications {
create<MavenPublication>("maven") {
from(components["kotlin"])
}
}
}
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}
rootProject.name = "third-party-lib"
enableFeaturePreview("GRADLE_METADATA")
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2020 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.
*/
package com.example.thirdparty
fun thirdPartyJsFun() {}