[Gradle, JS] Add test on JS IR IC case with multiple artifacts
This commit is contained in:
+52
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.gradle.util.normalizePath
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.condition.DisabledIf
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.util.zip.ZipFile
|
||||
@@ -169,6 +170,57 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("incremental compilation for JS IR consider multiple artifacts in one project")
|
||||
@GradleTest
|
||||
fun testJsIrIncrementalMultipleArtifacts(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-ir-ic-multiple-artifacts", gradleVersion) {
|
||||
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
build("compileDevelopmentExecutableKotlinJs") {
|
||||
val cacheDir = projectPath.resolve("app/build/klib/cache/lib/unspecified/")
|
||||
.toFile()
|
||||
assertTrue("Lib cache size should be 2") {
|
||||
cacheDir
|
||||
.list()
|
||||
?.size == 2
|
||||
}
|
||||
|
||||
var lib: Boolean = false
|
||||
var libOther: Boolean = false
|
||||
|
||||
cacheDir.listFiles()!!
|
||||
.forEach {
|
||||
it.listFiles()!!
|
||||
.single()
|
||||
.let {
|
||||
it.listFiles()!!
|
||||
.filter { it.isFile }
|
||||
.forEach {
|
||||
val text = it.readText()
|
||||
if (text.contains("<kotlin-js-ir-ic-multiple-artifacts:lib>")) {
|
||||
if (lib) {
|
||||
error("lib should be only once in cache")
|
||||
}
|
||||
lib = true
|
||||
}
|
||||
|
||||
if (text.contains("<kotlin-js-ir-ic-multiple-artifacts:lib_other>")) {
|
||||
if (libOther) {
|
||||
error("libOther should be only once in cache")
|
||||
}
|
||||
libOther = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue("lib and libOther should be once in cache") {
|
||||
lib && libOther
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
kotlin("js")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":lib"))
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
browser {
|
||||
}
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
|
||||
configurations["compileClasspath"].apply {
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, "kotlin-runtime"))
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* 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() {
|
||||
println("Sheldon: ${sheldon()}")
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
plugins {
|
||||
kotlin("js").version("<pluginMarkerVersion>").apply(false)
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0"
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
kotlin.incremental.js.klib=true
|
||||
kotlin.incremental.js.ir=true
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
plugins {
|
||||
kotlin("js")
|
||||
}
|
||||
|
||||
var conf: Configuration? = null
|
||||
|
||||
kotlin {
|
||||
js {
|
||||
val otherCompilation = compilations.create("other")
|
||||
tasks.register<Zip>("otherKlib") {
|
||||
from(otherCompilation.output.allOutputs)
|
||||
archiveExtension.set("klib")
|
||||
}
|
||||
|
||||
val otherDist by configurations.creating {
|
||||
isCanBeConsumed = true
|
||||
isCanBeResolved = false
|
||||
}
|
||||
conf = otherDist
|
||||
artifacts {
|
||||
add(otherDist.name, tasks.named("otherKlib").map { it.outputs.files.files.first() })
|
||||
}
|
||||
useCommonJs()
|
||||
browser {
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val main by getting {
|
||||
kotlin.exclude("**/other/**")
|
||||
dependencies {
|
||||
runtimeOnly(conf!!)
|
||||
}
|
||||
}
|
||||
val other by getting {
|
||||
kotlin.srcDirs("src/main/kotlin/other")
|
||||
dependencies {
|
||||
implementation(project(path = project.path))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* 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 answer(): Int {
|
||||
return 42
|
||||
}
|
||||
|
||||
fun sheldon(): Int {
|
||||
return 73
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* 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.other
|
||||
|
||||
fun foo(): Int {
|
||||
return 3
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
rootProject.name = "kotlin-js-ir-ic-multiple-artifacts"
|
||||
|
||||
include("lib")
|
||||
include("app")
|
||||
Reference in New Issue
Block a user