forked from googlearchive/js-store-locator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
43 lines (35 loc) · 846 Bytes
/
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
plugins {
id "com.eriwen.gradle.js" version "1.12.1"
}
javascript.source {
prod.js {
srcDir "js"
include "*.js"
}
}
minifyJs {
source = javascript.source.prod.js
dest = file("${buildDir}/store-locator.unwrapped.min.js")
closure.externs = fileTree(dir: "externs") + files("exports.js")
}
task wrap(type: WrapFileTask, dependsOn: minifyJs) {
inFile = minifyJs.dest
outFile = file("dist/store-locator.min.js")
wrapper = '(function($){%output%})(jQuery);'
}
task assemble(dependsOn: wrap)
// TODO(cbro): extract out into a gradle plugin.
class WrapFileTask extends DefaultTask {
@Input
String wrapper = '(function(){%output%})()'
@Input
File inFile
@Input
File outFile
@TaskAction
void wrap() {
outFile.withWriter { out ->
out.write(wrapper.split('%output%').join(inFile.text))
}
}
}