You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.7 KiB
86 lines
2.7 KiB
/*
|
|
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
|
|
*/
|
|
|
|
apply from: rootProject.file('gradle/node-js.gradle')
|
|
|
|
kotlin {
|
|
js {
|
|
// In 1.3.7x js() has not member `moduleName`
|
|
// In 1.4.x it has and allow to safety set compiler output file name and does not break test integration
|
|
if (it.hasProperty("moduleName")) {
|
|
moduleName = project.name
|
|
}
|
|
|
|
// In 1.3.7x js() has not member `irTarget`
|
|
// In 1.4.x it has in `both` and `legacy` mode and js() is of type `KotlinJsTarget`
|
|
// `irTarget` is non-null in `both` mode
|
|
// and contains appropriate `irTarget` with type `KotlinJsIrTarget`
|
|
// `irTarget` is null in `legacy` mode
|
|
if (it.hasProperty("irTarget") && it.irTarget != null) {
|
|
irTarget.nodejs()
|
|
irTarget.compilations['main']?.dependencies {
|
|
api "org.jetbrains.kotlinx:atomicfu-js:$atomicfu_version"
|
|
}
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
jsTest.dependencies {
|
|
api "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
|
}
|
|
}
|
|
}
|
|
|
|
// When source sets are configured
|
|
apply from: rootProject.file('gradle/test-mocha-js.gradle')
|
|
|
|
def compileJsLegacy = tasks.hasProperty("compileKotlinJsLegacy")
|
|
? compileKotlinJsLegacy
|
|
: compileKotlinJs
|
|
|
|
def compileTestJsLegacy = tasks.hasProperty("compileTestKotlinJsLegacy")
|
|
? compileTestKotlinJsLegacy
|
|
: compileTestKotlinJs
|
|
|
|
compileJsLegacy.configure {
|
|
kotlinOptions.metaInfo = true
|
|
kotlinOptions.sourceMap = true
|
|
kotlinOptions.moduleKind = 'umd'
|
|
|
|
kotlinOptions {
|
|
// drop -js suffix from outputFile
|
|
def baseName = project.name - "-js"
|
|
outputFile = new File(outputFile.parent, baseName + ".js")
|
|
}
|
|
}
|
|
|
|
compileTestJsLegacy.configure {
|
|
kotlinOptions.metaInfo = true
|
|
kotlinOptions.sourceMap = true
|
|
kotlinOptions.moduleKind = 'umd'
|
|
}
|
|
|
|
|
|
task populateNodeModules(type: Copy, dependsOn: compileTestJsLegacy) {
|
|
// we must copy output that is transformed by atomicfu
|
|
from(kotlin.js().compilations.main.output.allOutputs)
|
|
into "$node.nodeModulesDir/node_modules"
|
|
|
|
def configuration = configurations.hasProperty("jsLegacyTestRuntimeClasspath")
|
|
? configurations.jsLegacyTestRuntimeClasspath
|
|
: configurations.jsTestRuntimeClasspath
|
|
|
|
from(files {
|
|
configuration.collect { File file ->
|
|
file.name.endsWith(".jar") ?
|
|
zipTree(file.absolutePath).matching {
|
|
include '*.js'
|
|
include '*.js.map'
|
|
} : files()
|
|
}
|
|
}.builtBy(configuration))
|
|
}
|
|
|
|
npmInstall.dependsOn populateNodeModules
|