-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
123 lines (101 loc) · 3.3 KB
/
build.gradle.kts
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
import org.jetbrains.kotlin.gradle.frontend.KotlinFrontendExtension
import org.jetbrains.kotlin.gradle.frontend.karma.KarmaExtension
import org.jetbrains.kotlin.gradle.frontend.npm.NpmExtension
import org.jetbrains.kotlin.gradle.frontend.util.frontendExtension
import org.jetbrains.kotlin.gradle.frontend.webpack.WebPackExtension
import org.jetbrains.kotlin.gradle.plugin.Kotlin2JsPluginWrapper
import org.jetbrains.kotlin.gradle.tasks.KotlinJsDce
buildscript {
repositories {
jcenter()
maven {
setUrl("https://dl.bintray.com/kotlin/kotlin-eap")
}
mavenLocal()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.50")
classpath("org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.31")
}
}
plugins {
kotlin("platform.js") version "1.2.50"
}
apply {
plugin("org.jetbrains.kotlin.frontend")
plugin("kotlin-dce-js")
}
repositories {
jcenter()
}
dependencies {
compile(kotlin("stdlib-js"))
testCompile(kotlin("test-js"))
}
configure<KotlinFrontendExtension> {
downloadNodeJsVersion = "8.9.3"
sourceMaps = true
define("PRODUCTION", false)
configure<NpmExtension> {
// devDependency("kotlin-test", "1.2.31")
devDependency("karma")
// karma plugins
devDependency("karma-es6-shim")
devDependency("karma-mocha-reporter")
devDependency("karma-chrome-launcher")
}
configure<KarmaExtension> {
port = 9876
runnerPort = 9100
browsers = mutableListOf("ChromeHeadless")
plugins = mutableListOf("karma-mocha-reporter", "karma-es6-shim", "karma-chrome-launcher")
reporters = mutableListOf("mocha")
frameworks = mutableListOf("mocha", "es6-shim") // for now only qunit works as intended
}
bundle<WebPackExtension>("webpack") {
if (this is WebPackExtension) { // -> "Workaround" to be typesafe
bundleName = "main"
contentPath = file("src/main/web")
port = 3000
}
}
}
java.sourceSets {
getByName("main").java.srcDir("src/main/resources")
}
val jsOutputFile = "${project.buildDir}/js/${project.name}.js"
val testJsOutputFile = "${project.buildDir}/js-tests/${project.name}-tests.js"
tasks {
val compileKotlin2Js by getting(KotlinJsCompile::class) {
kotlinOptions.metaInfo = true
kotlinOptions.outputFile = jsOutputFile
kotlinOptions.sourceMap = true
kotlinOptions.sourceMapEmbedSources = "always"
kotlinOptions.moduleKind = "commonjs"
kotlinOptions.main = "call"
}
val compileTestKotlin2Js by getting(KotlinJsCompile::class) {
kotlinOptions.metaInfo = true
kotlinOptions.outputFile = testJsOutputFile
kotlinOptions.sourceMap = true
kotlinOptions.sourceMapEmbedSources = "always"
kotlinOptions.moduleKind = "commonjs"
kotlinOptions.main = "call"
}
val runDceTestKotlinJs by getting(KotlinJsDce::class) {
dceOptions {
devMode = true
}
}
val runDceKotlinJs by getting(KotlinJsDce::class) {
dceOptions {
devMode = false
}
}
}
project.afterEvaluate {
val `karma-run-single` by tasks.getting {
inputs.file(testJsOutputFile)
}
}