[Gradle, JS] Fix Gradle integration tests related with extracting dom api to separate module
- remove tests which were related with deprecated plugins - migrate some tests to new plugin instead of deprecated
This commit is contained in:
committed by
Space Team
parent
24cb10bbf3
commit
7a04c38863
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 sample
|
||||
|
||||
import kotlin.Pair
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 test.sample
|
||||
|
||||
import org.junit.Test as test
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 sample
|
||||
|
||||
import kotlinx.browser.document
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 test.sample
|
||||
|
||||
import org.junit.Test as test
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 sample
|
||||
|
||||
public fun main(args: Array<String>): Unit {
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 test.sample
|
||||
|
||||
import sample.Hello
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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 library.sample
|
||||
|
||||
import kotlin.js.Date
|
||||
|
||||
@@ -93,10 +93,6 @@
|
||||
<module>tools/kotlin-maven-plugin-test</module>
|
||||
|
||||
<module>examples/kotlin-java-example</module>
|
||||
<module>examples/js-example</module>
|
||||
<module>examples/kotlin-js-library-example</module>
|
||||
<module>examples/browser-example</module>
|
||||
<module>examples/browser-example-with-library</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
||||
+6
-2
@@ -6,6 +6,7 @@ import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilerExecutionStrategy
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.checkedReplace
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.*
|
||||
@@ -33,14 +34,17 @@ class IncrementalCompilationJsMultiProjectIT : BaseIncrementalCompilationMultiPr
|
||||
"implementation \"org.jetbrains.kotlin:kotlin-test-js:${'$'}kotlin_version\""
|
||||
|
||||
override val compileKotlinTaskName: String
|
||||
get() = "compileKotlin2Js"
|
||||
get() = "compileKotlinJs"
|
||||
|
||||
override val compileCacheFolderName: String
|
||||
get() = "caches-js"
|
||||
|
||||
//compileKotlin2Js's modification doe not work
|
||||
@Disabled("compileKotlinJs's modification does not work")
|
||||
override fun testFailureHandling_ToolError(gradleVersion: GradleVersion) {}
|
||||
|
||||
@Disabled("In JS IR all dependencies effectively api, not implementation")
|
||||
override fun testAddDependencyInLib(gradleVersion: GradleVersion) {}
|
||||
|
||||
@DisplayName("Add new dependency in lib project")
|
||||
@GradleTest
|
||||
override fun testAddDependencyInLib(gradleVersion: GradleVersion) {
|
||||
|
||||
+2
-77
@@ -183,8 +183,8 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
||||
}
|
||||
val cacheRootDir = cacheDir.resolve(cacheRootDirName!!)
|
||||
val klibCacheDirs = cacheRootDir.list()
|
||||
// 2 for lib.klib + 1 for stdlib + 1 for main
|
||||
assertEquals(4, klibCacheDirs?.size, "cache should contain 4 dirs")
|
||||
// 2 for lib.klib + 1 for stdlib + 1 for dom-api + 1 for main
|
||||
assertEquals(5, klibCacheDirs?.size, "cache should contain 4 dirs")
|
||||
|
||||
val libKlibCacheDirs = klibCacheDirs?.filter { dir -> dir.startsWith("lib.klib.") }
|
||||
assertEquals(2, libKlibCacheDirs?.size, "cache should contain 2 dirs for lib.klib")
|
||||
@@ -539,28 +539,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("js default output is included into jar")
|
||||
@GradleTest
|
||||
fun testJarIncludesJsDefaultOutput(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsNoOutputFileProject", gradleVersion) {
|
||||
build("jar") {
|
||||
checkIrCompilationMessage()
|
||||
|
||||
assertTasksExecuted(":compileKotlin2Js")
|
||||
val jarPath = projectPath.resolve("build/libs/kotlin2JsNoOutputFileProject.jar")
|
||||
assertFileExists(jarPath)
|
||||
ZipFile(jarPath.toFile()).use { jar ->
|
||||
if (!irBackend) {
|
||||
assertEquals(
|
||||
1, jar.entries().asSequence().count { it.name == "kotlin2JsNoOutputFileProject.js" },
|
||||
"The jar should contain an entry `kotlin2JsNoOutputFileProject.js` with no duplicates"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("js customized output is included into jar")
|
||||
@GradleTest
|
||||
fun testJarIncludesJsOutputSetExplicitly(gradleVersion: GradleVersion) {
|
||||
@@ -581,30 +559,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("moduleKind option works")
|
||||
@GradleTest
|
||||
fun testModuleKind(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsModuleKind", gradleVersion) {
|
||||
build("runRhino") {
|
||||
checkIrCompilationMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("default output file is generated")
|
||||
@GradleTest
|
||||
fun testDefaultOutputFile(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsNoOutputFileProject", gradleVersion) {
|
||||
build("build") {
|
||||
checkIrCompilationMessage()
|
||||
if (!irBackend) {
|
||||
assertFileExists(kotlinClassesDir().resolve("kotlin2JsNoOutputFileProject.js"))
|
||||
}
|
||||
assertFileExists(kotlinClassesDir(sourceSet = "test").resolve("kotlin2JsNoOutputFileProject_test.js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("test compilation can access main compilation")
|
||||
@GradleTest
|
||||
fun testCompileTestCouldAccessProduction(gradleVersion: GradleVersion) {
|
||||
@@ -630,37 +584,8 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
@GradleTest
|
||||
fun testCompilerTestAccessInternalProduction(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsInternalTest", gradleVersion) {
|
||||
build("runRhino") {
|
||||
checkIrCompilationMessage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("works with custom source sets")
|
||||
@GradleTest
|
||||
fun testJsCustomSourceSet(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsProjectWithCustomSourceset", gradleVersion) {
|
||||
build("build") {
|
||||
checkIrCompilationMessage()
|
||||
|
||||
assertTasksExecuted(
|
||||
":compileKotlin2Js",
|
||||
":compileIntegrationTestKotlin2Js"
|
||||
)
|
||||
|
||||
if (!irBackend) {
|
||||
assertFileInProjectExists("build/kotlin2js/main/module.js")
|
||||
}
|
||||
assertFileInProjectExists("build/kotlin2js/integrationTest/module-inttests.js")
|
||||
|
||||
val jarPath = projectPath.resolve("build/libs/kotlin2JsProjectWithCustomSourceset-inttests.jar")
|
||||
assertFileExists(jarPath)
|
||||
ZipFile(jarPath.toFile()).use { jar ->
|
||||
assertEquals(
|
||||
1, jar.entries().asSequence().count { it.name == "module-inttests.js" },
|
||||
"The jar should contain an entry `module-inttests.js` with no duplicates"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-36
@@ -550,42 +550,6 @@ class KotlinGradleIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Kotlin source directories are available in Java source directories")
|
||||
@GradleTest
|
||||
fun testKotlinSourceInJavaSourceSet(gradleVersion: GradleVersion) {
|
||||
project("multiplatformProject", gradleVersion) {
|
||||
val srcDirPrefix = "srcDir: "
|
||||
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
||||
subprojects { project ->
|
||||
project.afterEvaluate {
|
||||
project.sourceSets.each { sourceSet ->
|
||||
sourceSet.allJava.srcDirs.each { srcDir ->
|
||||
println "$srcDirPrefix" + srcDir.canonicalPath
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
val srcDirRegex = "$srcDirPrefix(.*)".toRegex()
|
||||
|
||||
build("help") {
|
||||
val reportedSrcDirs = srcDirRegex.findAll(output).map { it.groupValues[1] }.toSet()
|
||||
|
||||
val expectedKotlinDirs = listOf("lib", "libJvm", "libJs").flatMap { module ->
|
||||
listOf("main", "test").map { sourceSet ->
|
||||
projectPath.resolve("$module/src/$sourceSet/kotlin").toFile().absolutePath
|
||||
}
|
||||
}
|
||||
|
||||
expectedKotlinDirs.forEach { assertTrue(it in reportedSrcDirs, "$it should be included into the Java source sets") }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Default Kotlin version is not affected by transitive dependencies")
|
||||
@GradleTest
|
||||
fun testDefaultKotlinVersionIsNotAffectedByTransitiveDependencies(gradleVersion: GradleVersion) {
|
||||
|
||||
+8
-23
@@ -50,15 +50,11 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
":lib:compileTestKotlinCommon",
|
||||
":libJvm:compileKotlin",
|
||||
":libJvm:compileTestKotlin",
|
||||
":libJs:compileKotlin2Js",
|
||||
":libJs:compileTestKotlin2Js"
|
||||
)
|
||||
assertFileExists("lib/build/classes/kotlin/main/foo/PlatformClass.kotlin_metadata")
|
||||
assertFileExists("lib/build/classes/kotlin/test/foo/PlatformTest.kotlin_metadata")
|
||||
assertFileExists("libJvm/build/classes/kotlin/main/foo/PlatformClass.class")
|
||||
assertFileExists("libJvm/build/classes/kotlin/test/foo/PlatformTest.class")
|
||||
assertFileExists("libJs/build/classes/kotlin/main/libJs.js")
|
||||
assertFileExists("libJs/build/classes/kotlin/test/libJs_test.js")
|
||||
}
|
||||
|
||||
project.projectDir.resolve("gradle.properties").appendText("\nkotlin.internal.mpp12x.deprecation.suppress=true")
|
||||
@@ -113,7 +109,7 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
|
||||
// Make sure there is a plugin applied with the plugins DSL, so that Gradle loads the
|
||||
// plugins separately for the subproject, with a different class loader:
|
||||
File(projectDir, "libJs/build.gradle").modify {
|
||||
File(projectDir, "libJvm/build.gradle").modify {
|
||||
"plugins { id 'com.moowork.node' version '1.3.1' }" + "\n" + it
|
||||
}
|
||||
|
||||
@@ -124,7 +120,7 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
}
|
||||
|
||||
// Instead, add the dependencies directly to the subprojects buildscripts:
|
||||
listOf("lib", "libJvm", "libJs").forEach { subDirectory ->
|
||||
listOf("lib", "libJvm").forEach { subDirectory ->
|
||||
File(projectDir, "$subDirectory/build.gradle").modify {
|
||||
"""
|
||||
buildscript {
|
||||
@@ -150,9 +146,8 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
@Test
|
||||
fun testIncrementalBuild(): Unit = Project("multiplatformProject").run {
|
||||
val compileCommonTask = ":lib:compileKotlinCommon"
|
||||
val compileJsTask = ":libJs:compileKotlin2Js"
|
||||
val compileJvmTask = ":libJvm:compileKotlin"
|
||||
val allKotlinTasks = listOf(compileCommonTask, compileJsTask, compileJvmTask)
|
||||
val allKotlinTasks = listOf(compileCommonTask, compileJvmTask)
|
||||
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
@@ -170,15 +165,7 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(compileJvmTask)
|
||||
assertTasksUpToDate(compileCommonTask, compileJsTask)
|
||||
}
|
||||
|
||||
val jsProjectDir = File(projectDir, "libJs")
|
||||
jsProjectDir.getFileByName("PlatformClass.kt").modify { it + "\n" }
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(compileJsTask)
|
||||
assertTasksUpToDate(compileCommonTask, compileJvmTask)
|
||||
assertTasksUpToDate(compileCommonTask)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +178,7 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
val commonTasks = listOf("libA", "libB").flatMap { module ->
|
||||
sourceSets.map { sourceSet -> ":$module:compile${sourceSet}KotlinCommon" }
|
||||
}
|
||||
val platformTasks = listOf("libJvm" to "", "libJs" to "2Js").flatMap { (module, platformSuffix) ->
|
||||
val platformTasks = listOf("libJvm" to "").flatMap { (module, platformSuffix) ->
|
||||
sourceSets.map { sourceSet -> ":$module:compile${sourceSet}Kotlin$platformSuffix" }
|
||||
}
|
||||
assertTasksExecuted(commonTasks + platformTasks)
|
||||
@@ -219,11 +206,10 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
|
||||
gradleBuildScript("lib").appendText("\ncompileKotlinCommon.$overrideCompilerArgs")
|
||||
gradleBuildScript("libJvm").appendText("\ncompileKotlin.$overrideCompilerArgs")
|
||||
gradleBuildScript("libJs").appendText("\ncompileKotlin2Js.$overrideCompilerArgs")
|
||||
|
||||
build("build") {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":lib:compileKotlinCommon", ":libJvm:compileKotlin", ":libJs:compileKotlin2Js")
|
||||
assertTasksExecuted(":lib:compileKotlinCommon", ":libJvm:compileKotlin")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,14 +278,13 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
val sourceSetName = "foo"
|
||||
val sourceSetDeclaration = "\nsourceSets { $sourceSetName { } }"
|
||||
|
||||
listOf("lib", "libJvm", "libJs").forEach { module ->
|
||||
listOf("lib", "libJvm").forEach { module ->
|
||||
gradleBuildScript(module).appendText(sourceSetDeclaration)
|
||||
}
|
||||
|
||||
listOf(
|
||||
"expect fun foo(): String" to "lib/src/$sourceSetName/kotlin",
|
||||
"actual fun foo(): String = \"jvm\"" to "libJvm/src/$sourceSetName/kotlin",
|
||||
"actual fun foo(): String = \"js\"" to "libJs/src/$sourceSetName/kotlin"
|
||||
).forEach { (code, path) ->
|
||||
File(projectDir, path).run {
|
||||
mkdirs();
|
||||
@@ -307,7 +292,7 @@ class MultiplatformGradleIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
val customSourceSetCompileTasks = listOf(":lib" to "Common", ":libJs" to "2Js", ":libJvm" to "")
|
||||
val customSourceSetCompileTasks = listOf(":lib" to "Common", ":libJvm" to "")
|
||||
.map { (module, platform) -> "$module:compile${sourceSetName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}Kotlin$platform" }
|
||||
|
||||
build(*customSourceSetCompileTasks.toTypedArray(), options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)) {
|
||||
|
||||
+1
-6
@@ -1689,7 +1689,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
build(*params, options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":jvm-app:publishMainPublicationToMavenRepository")
|
||||
assertTasksExecuted(":js-app:publishMainPublicationToMavenRepository")
|
||||
assertTasksExecuted(":js-app:publishMavenPublicationToMavenRepository")
|
||||
|
||||
val jvmModuleDir = groupDir + "jvm-app/1.0/"
|
||||
val jsModuleDir = groupDir + "js-app/1.0/"
|
||||
@@ -1702,11 +1702,6 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
"<groupId>com.example</groupId><artifactId>mpp-lib-myjvm</artifactId><version>1.0</version><scope>compile</scope>"
|
||||
)
|
||||
}
|
||||
assertTrue("The JS POM should contain the dependency on 'mpp-lib' rewritten as 'mpp-lib-js'") {
|
||||
jsPom.contains(
|
||||
"<groupId>com.example</groupId><artifactId>mpp-lib-js</artifactId><version>1.0</version><scope>compile</scope>"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
assertTrue("The JVM POM should contain the original dependency on 'mpp-lib'") {
|
||||
jvmPom.contains(
|
||||
|
||||
-13
@@ -31,19 +31,6 @@ class UnnamedTaskInputsIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
@DisplayName("JS - kotlin2js plugin")
|
||||
@GradleTest
|
||||
fun inputsKotlin2Js(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsProject", gradleVersion) {
|
||||
enableLocalBuildCache(localBuildCacheDir)
|
||||
|
||||
build("assemble") {
|
||||
assertNoUnnamedInputsOutputs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
@DisplayName("JS")
|
||||
@GradleTest
|
||||
|
||||
+2
-33
@@ -131,31 +131,6 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsKtAppResolvesJsKtApp() {
|
||||
val outerProject = Project("kotlin2JsInternalTest", gradleVersion)
|
||||
val innerProject = Project("kotlin2JsNoOutputFileProject")
|
||||
|
||||
with(outerProject) {
|
||||
embedProject(innerProject)
|
||||
gradleBuildScript(innerProject.projectName).appendText("\ndependencies { implementation rootProject }")
|
||||
|
||||
gradleBuildScript(innerProject.projectName).appendText(
|
||||
// Newer Gradle versions fail to resolve the deprecated configurations because of variant-aware resolution ambiguity between
|
||||
// the *Elements configuration and its sub-variants (classes, resources)
|
||||
"\n" + """
|
||||
configurations {
|
||||
configure([compile, runtime, testCompile, testRuntime, getByName('default')]) {
|
||||
canBeResolved = false
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
testResolveAllConfigurations(innerProject.projectName, options = defaultBuildOptions().copy(warningMode = WarningMode.Summary))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMppResolvesJvmAndJsKtLibs() {
|
||||
val outerProject = Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")
|
||||
@@ -215,13 +190,11 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
fun testKtAppResolvesOldMpp() {
|
||||
val outerProject = Project("multiplatformProject")
|
||||
val innerJvmProject = Project("simpleProject")
|
||||
val innerJsProject = Project("kotlin2JsInternalTest")
|
||||
|
||||
with(outerProject) {
|
||||
embedProject(innerJvmProject)
|
||||
embedProject(innerJsProject)
|
||||
|
||||
listOf(innerJvmProject to ":libJvm", innerJsProject to ":libJs").forEach { (project, dependency) ->
|
||||
listOf(innerJvmProject to ":libJvm").forEach { (project, dependency) ->
|
||||
gradleBuildScript(project.projectName).appendText(
|
||||
"\n" + """
|
||||
dependencies {
|
||||
@@ -244,7 +217,7 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().appendText(
|
||||
"\n" + """
|
||||
configure([project(':lib'), project(':libJvm'), project(':libJs')]) {
|
||||
configure([project(':lib'), project(':libJvm')]) {
|
||||
group 'com.example.oldmpp'
|
||||
version '1.0'
|
||||
apply plugin: 'maven-publish'
|
||||
@@ -270,16 +243,12 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
gradleBuildScript("libJvm").appendText("\ndependencies { implementation 'com.example.oldmpp:libJvm:1.0' }")
|
||||
testResolveAllConfigurations("libJvm")
|
||||
|
||||
gradleBuildScript("libJs").appendText("\ndependencies { implementation 'com.example.oldmpp:libJs:1.0' }")
|
||||
testResolveAllConfigurations("libJs")
|
||||
|
||||
embedProject(Project("sample-lib", directoryPrefix = "new-mpp-lib-and-app"))
|
||||
gradleBuildScript("sample-lib").appendText(
|
||||
"\n" + """
|
||||
dependencies {
|
||||
commonMainApi 'com.example.oldmpp:lib:1.0'
|
||||
jvm6MainApi 'com.example.oldmpp:libJvm:1.0'
|
||||
nodeJsMainApi 'com.example.oldmpp:libJs:1.0'
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
-31
@@ -110,7 +110,6 @@ class KotlinProjectIT : KGPBaseTest() {
|
||||
project("multiplatformProject", gradleVersion) {
|
||||
getModels<KotlinProject> {
|
||||
val libKotlinProject = getModel(":lib")!!
|
||||
val libJsKotlinProject = getModel(":libJs")!!
|
||||
val libJvmKotlinProject = getModel(":libJvm")!!
|
||||
|
||||
libKotlinProject.assertBasics(
|
||||
@@ -118,44 +117,14 @@ class KotlinProjectIT : KGPBaseTest() {
|
||||
defaultBuildOptions.kotlinVersion,
|
||||
KotlinProject.ProjectType.PLATFORM_COMMON,
|
||||
)
|
||||
libJsKotlinProject.assertBasics(
|
||||
"libJs",
|
||||
defaultBuildOptions.kotlinVersion,
|
||||
KotlinProject.ProjectType.PLATFORM_JS,
|
||||
)
|
||||
libJvmKotlinProject.assertBasics(
|
||||
"libJvm",
|
||||
defaultBuildOptions.kotlinVersion,
|
||||
KotlinProject.ProjectType.PLATFORM_JVM,
|
||||
)
|
||||
|
||||
assertEquals(1, libJsKotlinProject.expectedByDependencies.size)
|
||||
assertTrue(libJsKotlinProject.expectedByDependencies.contains(":lib"))
|
||||
|
||||
assertEquals(1, libJvmKotlinProject.expectedByDependencies.size)
|
||||
assertTrue(libJvmKotlinProject.expectedByDependencies.contains(":lib"))
|
||||
|
||||
|
||||
assertEquals(2, libJsKotlinProject.sourceSets.size)
|
||||
val mainJsSourceSet = libJsKotlinProject.sourceSets.single { it.name == "main" }
|
||||
val testJsSourceSet = libJsKotlinProject.sourceSets.single { it.name == "test" }
|
||||
|
||||
mainJsSourceSet.assertBasics("main", SourceSet.SourceSetType.PRODUCTION, emptySet())
|
||||
testJsSourceSet.assertBasics("test", SourceSet.SourceSetType.TEST, listOf("main"))
|
||||
|
||||
assertEquals(1, mainJsSourceSet.sourceDirectories.size)
|
||||
assertTrue(mainJsSourceSet.sourceDirectories.contains(projectPath.resolve("libJs/src/main/kotlin").toFile()))
|
||||
assertEquals(1, mainJsSourceSet.resourcesDirectories.size)
|
||||
assertTrue(mainJsSourceSet.resourcesDirectories.contains(projectPath.resolve("libJs/src/main/resources").toFile()))
|
||||
assertEquals(projectPath.resolve("libJs/build/classes/kotlin/main").toFile(), mainJsSourceSet.classesOutputDirectory)
|
||||
assertEquals(projectPath.resolve("libJs/build/resources/main").toFile(), mainJsSourceSet.resourcesOutputDirectory)
|
||||
|
||||
assertEquals(1, testJsSourceSet.sourceDirectories.size)
|
||||
assertTrue(testJsSourceSet.sourceDirectories.contains(projectPath.resolve("libJs/src/test/kotlin").toFile()))
|
||||
assertEquals(1, testJsSourceSet.resourcesDirectories.size)
|
||||
assertTrue(testJsSourceSet.resourcesDirectories.contains(projectPath.resolve("libJs/src/test/resources").toFile()))
|
||||
assertEquals(projectPath.resolve("libJs/build/classes/kotlin/test").toFile(), testJsSourceSet.classesOutputDirectory)
|
||||
assertEquals(projectPath.resolve("libJs/build/resources/test").toFile(), testJsSourceSet.resourcesOutputDirectory)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -1,7 +1,15 @@
|
||||
apply plugin: 'org.jetbrains.kotlin.platform.js'
|
||||
apply plugin: 'org.jetbrains.kotlin.js'
|
||||
|
||||
dependencies {
|
||||
implementation project(':lib')
|
||||
// do not remove until KT-25488 is fixed
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
nodejs {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -1,6 +1,12 @@
|
||||
apply plugin: 'org.jetbrains.kotlin.platform.js'
|
||||
apply plugin: 'org.jetbrains.kotlin.js'
|
||||
|
||||
dependencies {
|
||||
// do not remove until KT-25488 is fixed
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
+5
-40
@@ -8,7 +8,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'org.jetbrains.kotlin.platform.js'
|
||||
apply plugin: 'org.jetbrains.kotlin.js'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
@@ -17,47 +17,12 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
implementation "org.mozilla:rhino:1.7.7.1"
|
||||
}
|
||||
|
||||
def classesDir = "${buildDir}/classes/kotlin"
|
||||
kotlin {
|
||||
js {
|
||||
nodejs {
|
||||
|
||||
def isIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() ?: false
|
||||
if (isIrBackend) {
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
}
|
||||
|
||||
task runRhino(type: JavaExec) {
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
workingDir = classesDir
|
||||
main = 'org.mozilla.javascript.tools.shell.Main'
|
||||
if (isIrBackend) {
|
||||
// IR backend produces a single JS file
|
||||
args = ["-opt", "-1", "test/kotlin2JsInternalTest_test.js", "-f", "check.js"]
|
||||
} else {
|
||||
args = ["-opt", "-1", "-f", "kotlin.js", "-f", "main/kotlin2JsInternalTest.js", "-f", "test/kotlin2JsInternalTest_test.js", "-f", "check.js"]
|
||||
}
|
||||
}
|
||||
|
||||
build.doLast {
|
||||
configurations.compileClasspath.each { File file ->
|
||||
copy {
|
||||
includeEmptyDirs = false
|
||||
|
||||
from zipTree(file.absolutePath)
|
||||
into classesDir
|
||||
include { fileTreeElement ->
|
||||
def path = fileTreeElement.path
|
||||
path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
copy {
|
||||
from "."
|
||||
include "check.js"
|
||||
into classesDir
|
||||
}
|
||||
}
|
||||
|
||||
runRhino.dependsOn build
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
internal val CONST = "CONST"
|
||||
|
||||
open class PublicClass {
|
||||
internal fun foo(): String = "foo"
|
||||
fun foo(): String = "foo"
|
||||
internal val bar: String = "bar"
|
||||
open internal fun baz(): String = "PublicClass.baz()"
|
||||
}
|
||||
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'org.jetbrains.kotlin.platform.js'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
integrationTest
|
||||
}
|
||||
|
||||
task integrationTest(type: Test) {
|
||||
testClassesDirs = sourceSets.integrationTest.output.classesDirs
|
||||
classpath = sourceSets.integrationTest.runtimeClasspath
|
||||
}
|
||||
|
||||
compileIntegrationTestKotlin2Js.dependsOn compileKotlin2Js
|
||||
|
||||
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
|
||||
compileIntegrationTestKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/integrationTest/module-inttests.js"
|
||||
|
||||
def isIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() ?: false
|
||||
if (isIrBackend) {
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
compileIntegrationTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
integrationTestImplementation files(compileKotlin2Js.destinationDirectory)
|
||||
integrationTestImplementation "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||
}
|
||||
|
||||
task integrationTestJar(type: Jar) {
|
||||
from sourceSets.integrationTest.output
|
||||
from sourceSets.integrationTest.kotlin.classesDirectory
|
||||
classifier = 'inttests'
|
||||
}
|
||||
|
||||
build.dependsOn integrationTestJar
|
||||
|
||||
task jarSources(type: Jar) {
|
||||
from sourceSets.main.allSource
|
||||
classifier = 'source'
|
||||
}
|
||||
artifacts {
|
||||
implementation jarSources
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package test
|
||||
|
||||
import example.MyProductionClass
|
||||
import kotlin.test.Test
|
||||
|
||||
class MainIT {
|
||||
@Test
|
||||
fun mySimpleTest() {
|
||||
listOf(1, 2, 3).forEach { // check that stdlib is available
|
||||
MyProductionClass().i = it // check that production code is available
|
||||
}
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package example
|
||||
|
||||
class MyProductionClass {
|
||||
var i = 0
|
||||
}
|
||||
+8
-14
@@ -1,22 +1,16 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "maven-publish"
|
||||
id "org.jetbrains.kotlin.js"
|
||||
}
|
||||
|
||||
apply plugin: 'org.jetbrains.kotlin.platform.js'
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0"
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js"
|
||||
}
|
||||
@@ -41,8 +35,8 @@ if (project.findProperty("mppProjectDependency") == "true") {
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
main(MavenPublication) {
|
||||
from components.java
|
||||
maven(MavenPublication) {
|
||||
from components["kotlin"]
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
|
||||
dependencies {
|
||||
expectedBy project(":libA")
|
||||
expectedBy project(":libB")
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package foo
|
||||
|
||||
actual class PlatformClassA {
|
||||
actual val valueA: String = "JS"
|
||||
}
|
||||
|
||||
actual class PlatformClassB {
|
||||
actual val valueB: String = "JS"
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package foo
|
||||
|
||||
actual class PlatformTestA {
|
||||
actual val valueA: PlatformClassA = PlatformClassA()
|
||||
}
|
||||
|
||||
actual class PlatformTestB {
|
||||
actual val valueB: PlatformClassB = PlatformClassB()
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
|
||||
dependencies {
|
||||
expectedBy project(":lib")
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package foo
|
||||
|
||||
actual class PlatformClass {
|
||||
actual val value: String = "JS"
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package foo
|
||||
|
||||
actual class PlatformTest {
|
||||
actual val value: PlatformClass = PlatformClass()
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
include ':lib', ':libJvm', ':libJs'
|
||||
include ':lib', ':libJvm'
|
||||
Reference in New Issue
Block a user