[Gradle, JS] Add test on adding dom-api-compat library
This commit is contained in:
committed by
Space Team
parent
b794496bb9
commit
68d5619af4
+172
-1
@@ -700,7 +700,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
||||||
val mapFilePath = subProject("app").projectPath
|
val mapFilePath = subProject("app").projectPath
|
||||||
.resolve("build/kotlin2js/app.js.map")
|
.resolve("build/kotlin2js/app.js.map")
|
||||||
assertFileContains(mapFilePath,"\"../../src/main/kotlin/main.kt\"")
|
assertFileContains(mapFilePath, "\"../../src/main/kotlin/main.kt\"")
|
||||||
if (irBackend) {
|
if (irBackend) {
|
||||||
// The IR BE generates correct paths for dependencies
|
// The IR BE generates correct paths for dependencies
|
||||||
assertFileContains(mapFilePath, "\"../../../lib/src/main/kotlin/foo.kt\"")
|
assertFileContains(mapFilePath, "\"../../../lib/src/main/kotlin/foo.kt\"")
|
||||||
@@ -1713,4 +1713,175 @@ class GeneralKotlin2JsGradlePluginIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("Kotlin/JS DOM API extracting automatically added as dependency")
|
||||||
|
@GradleTest
|
||||||
|
fun testKotlinJsBuiltins(gradleVersion: GradleVersion) {
|
||||||
|
project("kotlin-js-dom-api-compat", gradleVersion) {
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksExecuted(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
var added: String? = null
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
it + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksUpToDate(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
val replaced = it.replace(added!!, "")
|
||||||
|
replaced + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-dom-api-compat")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksUpToDate(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
val replaced = it.replace(added!!, "")
|
||||||
|
replaced + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-dom-api-compat")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksUpToDate(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
val replaced = it.replace(added!!, "")
|
||||||
|
replaced
|
||||||
|
}
|
||||||
|
|
||||||
|
gradleProperties.modify {
|
||||||
|
it + "\n" +
|
||||||
|
"""
|
||||||
|
kotlin.stdlib.default.dependency=false
|
||||||
|
""".trimIndent()
|
||||||
|
}
|
||||||
|
|
||||||
|
buildAndFail("assemble") {
|
||||||
|
assertTasksFailed(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
it + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
buildAndFail("assemble") {
|
||||||
|
assertTasksFailed(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
val replaced = it.replace(added!!, "")
|
||||||
|
replaced + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-dom-api-compat")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksExecuted(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
val replaced = it.replace(added!!, "")
|
||||||
|
replaced + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-dom-api-compat")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksUpToDate(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
val replaced = it.replace(added!!, "")
|
||||||
|
replaced
|
||||||
|
}
|
||||||
|
|
||||||
|
gradleProperties.modify {
|
||||||
|
val replaced = it.replace(
|
||||||
|
"kotlin.stdlib.default.dependency=false",
|
||||||
|
"kotlin.js.stdlib.dom.api.included=false"
|
||||||
|
)
|
||||||
|
replaced
|
||||||
|
}
|
||||||
|
|
||||||
|
buildAndFail("assemble") {
|
||||||
|
assertTasksFailed(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
it + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
buildAndFail("assemble") {
|
||||||
|
assertTasksFailed(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
val replaced = it.replace(added!!, "")
|
||||||
|
replaced + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-dom-api-compat")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksUpToDate(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
|
||||||
|
buildGradleKts.modify {
|
||||||
|
val replaced = it.replace(added!!, "")
|
||||||
|
replaced + "\n" +
|
||||||
|
"""
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-dom-api-compat")
|
||||||
|
}
|
||||||
|
""".trimIndent().also { added = it }
|
||||||
|
}
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksUpToDate(":compileKotlinJs")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("js")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
js {
|
||||||
|
browser {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = "kotlin-js-browser"
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 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
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
org.w3c.performance.Performance::class.js
|
||||||
|
org.khronos.webgl.WebGLContextEvent
|
||||||
|
kotlinx.browser.window
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user