-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathbuild.gradle
54 lines (47 loc) · 1.72 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
apply plugin: 'kotlin-dce-js'
apply from: rootProject.file('gradle/node-js.gradle')
// Workaround resolving new Gradle metadata with kotlin2js
// TODO: Remove once KT-37188 is fixed
try {
def jsCompilerType = Class.forName("org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute")
def jsCompilerAttr = Attribute.of("org.jetbrains.kotlin.js.compiler", jsCompilerType)
project.dependencies.attributesSchema.attribute(jsCompilerAttr)
configurations {
matching {
it.name.endsWith("Classpath")
}.forEach {
it.attributes.attribute(jsCompilerAttr, jsCompilerType.legacy)
}
}
} catch (java.lang.ClassNotFoundException e) {
// org.jetbrains.kotlin.gradle.targets.js.JsCompilerType is missing in 1.3.x
// But 1.3.x doesn't generate Gradle metadata, so this workaround is not needed
}
dependencies {
compile "org.jetbrains.kotlinx:kotlinx-html-js:$html_version"
}
compileKotlin2Js {
kotlinOptions {
main = "call"
}
}
task bundle(type: NpmTask, dependsOn: [npmInstall, runDceKotlinJs]) {
inputs.files(fileTree("$buildDir/kotlin-js-min/main"))
inputs.files(fileTree(file("src/main/web")))
inputs.file("npm/webpack.config.js")
outputs.dir("$buildDir/dist")
args = ["run", "bundle"]
}
task start(type: NpmTask, dependsOn: bundle) {
args = ["run", "start"]
}
// we have not tests but kotlin-dce-js still tries to work with them and crashed.
// todo: Remove when KT-22028 is fixed
afterEvaluate {
if (tasks.findByName('unpackDependenciesTestKotlinJs')) {
tasks.unpackDependenciesTestKotlinJs.enabled = false
}
}