-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
95 lines (77 loc) · 2.36 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
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
group 'kotlin-browser-example'
version '1.0.0-PREVIEW'
task wrapper(type: Wrapper) {
gradleVersion = '4.6'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
buildscript {
ext.kotlinVersion = '1.2.30'
repositories {
jcenter()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'com.moowork.gradle:gradle-node-plugin:1.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
apply plugin: 'kotlin-platform-js'
apply plugin: 'kotlin-dce-js'
apply plugin: 'com.moowork.node'
repositories {
jcenter()
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url "https://kotlin.bintray.com/kotlinx" }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion"
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion"
}
node {
download true
}
compileKotlin2Js {
kotlinOptions {
metaInfo = true
sourceMap = true
sourceMapEmbedSources = 'always'
moduleKind = 'umd'
}
}
compileTestKotlin2Js {
kotlinOptions.moduleKind = 'umd'
}
// Downloads JS dependencies
task yarnInstall(type: YarnTask) {
args = ['install']
}
// Creates minified, packed main.bundle.js at build/dist
task bundle(type: YarnTask, dependsOn: [runDceKotlinJs, yarnInstall]) {
args = ["run", "bundle"]
assemble.dependsOn bundle
}
// Copies files from src/main/resouces to build/dist. These resources will be served by dev server
task copyStaticResources(type: Copy) {
from sourceSets.main.resources
into "${buildDir}/dist"
bundle.dependsOn copyStaticResources
}
// Extracts JS libs from included dependencies to node_modules in build directory:
task populateNodeModules(type: Copy, dependsOn: compileKotlin2Js) {
from compileKotlin2Js.destinationDir
configurations.testCompile.each {
from zipTree(it.absolutePath).matching { include '*.js' }
}
into "${buildDir}/node_modules"
}
// Starts dev server that serves built application in dev mode
task run(type: YarnTask, dependsOn: [copyStaticResources, populateNodeModules, yarnInstall]) {
args = ["run", "start"]
}
// Test runner
task runKarma(type: YarnTask, dependsOn: [populateNodeModules, yarnInstall]) {
args = ['test']
test.dependsOn runKarma
}