forked from free-jqgrid/jqGrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
124 lines (101 loc) · 3.68 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
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
124
configurations {
jscompiler
}
repositories {
mavenCentral()
}
dependencies {
jscompiler 'com.google.javascript:closure-compiler:v20151015'
}
def srcdir = new File('js')
def distdir = new File('dist')
def jqGridFile = new File(distdir, 'jquery.jqgrid.src.js')
def jqGridMinFile = new File(distdir, 'jquery.jqgrid.min.js')
def jqGridSrcMapFile = new File(distdir, 'jquery.jqgrid.min.map')
task init() {
description = "Create distribution directory: $distdir.absolutePath"
outputs.dir distdir
doLast {
if (!distdir.exists()) {
distdir.mkdirs()
}
}
}
task jqgrid(dependsOn: 'init') {
description = "Concatinate all javascript files into one javascript file: $jqGridFile.absolutePath"
def files = fileTree(dir: srcdir, include: '*.js', exclude: 'jquery.jqgrid.*.js')
inputs.file files
outputs.file jqGridFile
doLast {
ant.concat(destfile: jqGridFile) {
files.each { fileset(file: it) }
}
}
}
task 'jqgrid-min'(dependsOn: 'jqgrid') {
description = "Minimize $jqGridFile.absolutePath to $jqGridMinFile.absolutePath"
def outputMapFile = new File(srcdir, 'jquery.jqgrid.min.map')
inputs.file jqGridFile
outputs.file jqGridMinFile
doLast {
ant.taskdef(name: 'jscompile', classname: 'com.google.javascript.jscomp.ant.CompileTask', classpath: configurations.jscompiler.asPath)
ant.jscompile(output: jqGridMinFile, warning: 'QUIET', sourceMapFormat: 'V3', sourceMapOutputFile: jqGridSrcMapFile, debug: logger.debugEnabled) {
ant.sources(dir: jqGridFile.parent) {
ant.file(name: jqGridFile.name)
}
}
def fileContent = jqGridSrcMapFile.getText()
fileContent = fileContent.replace('"sources":["dist/jquery.jqgrid.src.js"],', '"sources":["jquery.jqgrid.src.js"],')
outputMapFile.write(fileContent)
}
}
task 'min-files'(dependsOn: 'init') {
def minDir = new File(distdir, 'min')
description = "Minimize all javascript files to $minDir.absolutePath"
def files = fileTree(dir: srcdir, include: '*.js')
inputs.file files
outputs.dir minDir
doLast {
if (!minDir.exists()) {
minDir.mkdirs()
}
ant.taskdef(name: 'jscompile', classname: 'com.google.javascript.jscomp.ant.CompileTask', classpath: configurations.jscompiler.asPath)
files.each { File f ->
ant.jscompile(output: new File(minDir, f.name), warning: 'QUIET', debug: logger.debugEnabled) {
ant.sources(dir: f.parent) {
ant.file(name: f.name)
}
}
}
}
}
task i18n(type: Copy, dependsOn: 'init') {
def i18nDir = new File(distdir, 'i18n')
description = "Copy all i18n files to $i18nDir.absolutePath"
duplicatesStrategy = 'exclude'
from new File(srcdir, 'i18n')
into i18nDir
include('grid.locale-*.js')
}
task copySrcAndMin(type: Copy, dependsOn: 'jqgrid-min') {
description = "Copy $jqGridFile and $jqGridMinFile files to $srcdir.absolutePath"
delete new File(srcdir, 'jquery.jqgrid.src.js'), new File(srcdir, 'jquery.jqgrid.min.js')
from distdir
into srcdir
include('jquery.jqgrid*.js')
}
task clean() {
description = "Delete distribution directory: $distdir.absolutePath"
doLast {
if (distdir.exists()) {
distdir.deleteDir()
}
delete new File(srcdir, 'jquery.jqgrid.min.map')
}
}
task build(dependsOn: ['jqgrid-min', 'i18n', 'copySrcAndMin']) {
description = "Build the entire distribution"
}
task wrap(type: Wrapper) {
gradleVersion = '2.8'
}