-
Notifications
You must be signed in to change notification settings - Fork 38
/
build.gradle
106 lines (90 loc) · 2.7 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
defaultTasks 'minify'
def VERSION_LINE = / \* writeCapture\.js v((\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?)/
task upVersion << {
def script = new File('writeCapture.js')
def text = script.text.replaceAll(VERSION_LINE) { line, v, major, minor, fix, snapshot ->
if(!snapshot) {
// if snapshot wasn't in there, increment the version number
fix = fix.toInteger() + 1
}
" * writeCapture.js v${major}.${minor}.${fix}"
}
script.write(text)
}
def getVersion = {
(new File('writeCapture.js').filterLine {
it =~ VERSION_LINE
} =~ VERSION_LINE)[0][1]
}
def doMinify = {
ant.java(jar:'build/yuicompressor-2.4.2.jar',fork:true) {
arg(value:'-o')
arg(value:"writeCapture-${getVersion()}-min.js")
arg(value:'writeCapture.js')
}
}
def doConcat = {
ant.concat(destfile:'build-concat.tmp.js') {
fileset(dir:'support',includes:'nolib-support.js')
fileset(dir:'.',includes:'writeCapture.js')
}
}
def doConcatPlugin = {
ant.concat(destfile:'plugin-concat.tmp.js') {
fileset(dir:'.',includes:'writeCapture.js')
fileset(dir:'plugin',includes:'jquery.writeCapture.js')
}
}
def doConcatCjs = {
ant.concat(destfile:'cjs-concat.tmp.js') {
fileset(dir:'support',includes:'nolib-support.js')
fileset(dir:'.',includes:'writeCapture.js')
fileset(dir:'.',includes:'cjs.writeCapture.js')
}
}
task concat << doConcat
task concatPlugin << doConcatPlugin
task concatCjs << doConcatCjs
def doMinifyNolib = {
ant.java(jar:'build/yuicompressor-2.4.2.jar',fork:true) {
arg(value:'-o')
arg(value:"writeCapture-${getVersion()}-nolib-min.js")
arg(value:'build-concat.tmp.js')
}
ant.delete(file:'build-concat.tmp.js')
}
def doMinifyCjs = {
ant.java(jar:'build/yuicompressor-2.4.2.jar',fork:true) {
arg(value:'-o')
arg(value:"writeCapture-${getVersion()}-forCjs-min.js")
arg(value:'cjs-concat.tmp.js')
}
ant.delete(file:'cjs-concat.tmp.js')
}
def doMinifyPlugin = {
ant.java(jar:'build/yuicompressor-2.4.2.jar',fork:true) {
arg(value:'-o')
arg(value:"jquery.writeCapture-${getVersion()}-min.js")
arg(value:'plugin-concat.tmp.js')
}
ant.delete(file:'plugin-concat.tmp.js')
}
task minifyNolib(dependsOn:'concat') << doMinifyNolib
task minifyPlugin(dependsOn:'concatPlugin') << doMinifyPlugin
task minifyCjs(dependsOn:'concatCjs') << doMinifyCjs
task minify << doMinify
task release(dependsOn:['upVersion']) << {
// putting minify in dependsOn causes it to run before upVersion... WTF?
doMinify()
doConcat()
doMinifyNolib()
doConcatPlugin()
doMinifyPlugin()
doConcatCjs()
doMinifyCjs()
def version = getVersion()
println "Releasing v${version}"
println "You should:"
println " git commit -am 'releasing version ${version}'"
println " git tag -a v${version} -m 'tagging release v${version}'"
}