forked from eriwen/gradle-js-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.gradle
94 lines (81 loc) · 2.42 KB
/
plugin.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
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath 'com.eriwen:gradle-js-plugin:1.8.0'
}
}
buildscript {
configurations.classpath.resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'js'
javascript.source {
custom {
js {
srcDir "src/test/resources"
include "file*.js"
}
}
}
task clean(type: Delete) {
delete buildDir
}
// Combine JS files
task combine(type: com.eriwen.gradle.js.tasks.CombineJsTask) {
source = javascript.source.custom.js.files
dest = "${buildDir}/all.js"
}
requireJs {
source = javascript.source.custom.js.files
dest = "$buildDir/require.js"
requirejs.buildprofile = new File("src/test/resources/requirejs/build.js")
}
// Minify with Google Closure Compiler
minifyJs {
dest = file("${buildDir}/all-min.js")
source = javascript.source.custom.js.files
closure {
warningLevel = 'VERBOSE'
compilationLevel = 'SIMPLE_OPTIMIZATIONS'
externs = files("src/test/resources/externs.js")
}
}
javascript.source.custom.js.files.eachWithIndex { jsFile, idx ->
tasks.add(name: "dominify${idx}", type: com.eriwen.gradle.js.tasks.MinifyJsTask) {
source = jsFile
dest = "${buildDir}/${jsFile.name}"
}
}
task individualMinify(dependsOn: tasks.matching { Task task -> task.name.startsWith("dominify")})
// For auto-versioning
//def version = Integer.toHexString(Integer.parseInt(new java.text.SimpleDateFormat('yyDDHHmm').format(new Date())))
def version = "1.7.2"
// GZip it!
task gzip(type: com.eriwen.gradle.js.tasks.GzipJsTask) {
source = minifyJs
dest = "${buildDir}/all-${version}.min.js"
}
task jshintz(type: com.eriwen.gradle.js.tasks.JsHintTask) {
source = javascript.source.custom.js.files
dest = "${buildDir}/jshint.out"
ignoreExitCode = true
reporter = 'checkstyle'
jshint.options = [expr: "true", unused: "true"]
jshint.predef = ["exports": 1]
}
task jsdocz(type: com.eriwen.gradle.js.tasks.JsDocTask) {
source = javascript.source.custom.js.files
destinationDir = "${buildDir}/jsdoc"
}
task props(type: com.eriwen.gradle.js.tasks.Props2JsTask) {
source = file("${projectDir}/src/test/resources/test.properties")
dest = file("${buildDir}/props.jsonp")
project.props.type = 'jsonp'
project.props.functionName = 'fn'
}