-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
66 lines (57 loc) · 1.5 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
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "com.moowork.gradle:gradle-node-plugin:0.11"
}
}
apply plugin: "com.moowork.node"
node {
version = '0.12.6'
npmVersion = '2.10.1'
download = true
}
//npm dependencies caching for a faster build
task npmCacheConfig(type: NpmTask) {
description = "Configure the NPM cache"
def npmCacheDir = "${gradle.getGradleUserHomeDir()}/caches/npm"
outputs.files file(npmCacheDir)
args = [ 'config', 'set', 'cache', npmCacheDir ]
}
//Install npm packages from
task npmPackages(type: NpmTask, dependsOn: npmCacheConfig) {
description = "Install Node.js packages"
args = [ 'install' ]
inputs.files file('package.json')
outputs.files file('node_modules')
}
task buildServer(type: NodeTask, dependsOn: npmPackages) {
script = file('node_modules/enclose/bin/enclose.js')
args = ['--loglevel',
'info',
'-x',
'-o',
'server',
'server.js']
}
task buildClient(type: NodeTask, dependsOn: npmPackages) {
script = file('node_modules/enclose/bin/enclose.js')
args = ['--loglevel',
'info',
'-x',
'-o',
'client',
'client.js']
}
task build(dependsOn: ['buildServer', 'buildClient']) {
println "Compile Server and Client."
}
task runServer(type: NodeTask) {
script = file('server.js')
}
task runClient(type: NodeTask) {
script = file('client.js')
}