-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
266 lines (207 loc) · 9.49 KB
/
build.xml
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?xml version="1.0"?>
<project name="algid-i18n" default="minify" basedir=".">
<!-- Include the property files -->
<property file="${basedir}/build/settings/user.properties"/>
<property file="${basedir}/build/settings/project.properties"/>
<property file="${basedir}/build/settings/version.properties"/>
<property file="${basedir}/build/settings/build.properties"/>
<property file="${basedir}/build/settings/test.properties"/>
<target name="minify" depends="prepare" description="Minify the CSS and JS files">
<echo message="Starting: CSS and JS minification"/>
<!-- Create a single, concatenated JS file
<concat destfile="${build.script}jquery.${project.key}.js">
<fileset dir="${build.script}" includes="jquery.base.js" />
</concat> -->
<!-- Create a single, concatenated CSS file
<concat destfile="${build.style}${project.key}.css">
<fileset dir="${build.style}" includes="base.css" />
</concat> -->
<!-- Compress the JS files with Google Closure Compiler -->
<apply executable="java" parallel="false" dest="${basedir}/${project.key}">
<fileset dir="${basedir}${file.separator}${project.key}" includes="**/*.js" excludes="**/*-min.js" />
<arg line="-jar"/>
<arg path="${build.lib}${file.separator}${build.lib.jar.compiler}" />
<arg line="--js"/>
<srcfile/>
<arg line="--js_output_file"/>
<mapper type="glob" from="*.js" to="*-min.js"/>
<targetfile/>
</apply>
<!-- Compress the CSS files with Yahoo UI Compressor -->
<apply executable="java" parallel="false" dest="${basedir}/${project.key}">
<fileset dir="${basedir}${file.separator}${project.key}" includes="**/*.css" excludes="**/*-min.css" />
<arg line="-jar"/>
<arg path="${build.lib}${file.separator}${build.lib.jar.compressor}" />
<arg line="-v"/>
<srcfile/>
<arg line="-o"/>
<mapper type="glob" from="*.css" to="*-min.css"/>
<targetfile/>
</apply>
<echo message="Finished: CSS and JS minification"/>
</target>
<target name="prepare">
<echo message="Starting: Environment Preparation"/>
<!-- Make the distribution directory -->
<mkdir dir="${build.dist}" />
<!-- Make the log directory -->
<mkdir dir="${build.logs}" />
<!-- Make the unit test directory -->
<mkdir dir="${build.dist}/unit" />
<!-- Define log file -->
<record name="${build.logs}${file.separator}${build.logs.ant}" />
<!-- Create the time stamp -->
<tstamp>
<format property="build.date" pattern="MM/dd/yy hh:mmaa"/>
</tstamp>
<!-- Combine the version parts into full version identifier -->
<property name="project.version" value="${project.version.major}.${project.version.minor}.${project.version.build}"/>
<!-- Set the script directory -->
<property name="build.script" value="${basedir}${file.separator}${project.key}${file.separator}script${file.separator}"/>
<!-- Set the style directory -->
<property name="build.style" value="${basedir}${file.separator}${project.key}${file.separator}style${file.separator}"/>
<echo message="Finished: Environment Preparation"/>
</target>
<target name="release" depends="prepare,minify,testVarScoper,testMXUnit" description="Tags a release">
<echo message="Starting: Release of version ${project.version}" />
<!-- Start a release branch -->
<git command="flow" dir="${basedir}">
<args>
<arg value="release" />
<arg value="start" />
<arg value="${project.version}" />
</args>
</git>
<!-- Update the release version number -->
<replaceregexp file="${basedir}/version.json"
match=""version": "[0-9\.]*""
replace=""version": "${project.version}""
byline="true"/>
<!-- Update the download version number -->
<replaceregexp file="${basedir}/version.json"
match="tarball/[0-9\.]*""
replace="tarball/${project.version}""
byline="true"
/>
<!-- Finish a release branch -->
<git command="commit" dir="${basedir}">
<args>
<arg value="-a" />
<arg value="-m 'Updated version files for release'" />
</args>
</git>
<!-- Finish a release branch -->
<git command="flow" dir="${basedir}">
<args>
<arg value="release" />
<arg value="finish" />
<arg value="${project.version}" />
<arg value="-m 'Tagging version ${project.version}'" />
</args>
</git>
<!-- Update the build version -->
<propertyfile file="${build}/settings/version.properties" comment="Version properties">
<entry key="project.version.build" value="1" operation="+" type="int"/>
</propertyfile>
<antcall target="versionChanged" inheritall="false" inheritrefs="false"></antcall>
<!-- Commit the updated version files -->
<git command="commit" dir="${basedir}">
<args>
<arg value="-a" />
<arg value="-m 'Updated version properties for next release'" />
</args>
</git>
<echo message="Finished: Release of version ${project.version}"/>
</target>
<target name="testJSLint" depends="prepare" description="Runs the JSLint Tests">
<echo message="Starting: JSLint Tests"/>
<!-- Make the unit test directory -->
<mkdir dir="${build.dist}/jslint" />
<!-- Load ANT tasks -->
<taskdef name="jslint" classname="com.googlecode.jslint4java.ant.JSLintTask" classpath="${build.lib}${file.separator}${build.lib.jar.jslint}" />
<jslint options="eqeqeq,immed,passfail">
<formatter type="plain" />
<formatter type="xml" destfile="${build.dist}/jslint/jslint.xml" />
<fileset dir="${test.jslint.filePath}" casesensitive="yes">
<include name="**/*.js"/>
<exclude name="**/*-min.js"/>
</fileset>
</jslint>
<echo message="Finished: JSLint Tests"/>
</target>
<target name="testMXUnit" depends="prepare" description="Runs the Unit Tests">
<echo message="Starting: Unit Tests"/>
<!-- Load ANT tasks -->
<taskdef name="mxunittask" classname="org.mxunit.ant.MXUnitAntTask" classpath="${build.lib}${file.separator}${build.lib.jar.mxunit}" />
<mxunittask server="${test.host}" port="${test.port}" outputdir="${build.dist}/unit" defaultrunner="${test.mxunit.defaultrunner}" failureproperty="test.mxunit.failure" verbose="${general.verbose}">
<directory path="${basedir}/test" componentPath="${test.mxunit.componentpath}" recurse="true" />
</mxunittask>
<fail if="test.mxunit.failure" message="Unit tests failed" />
<echo message="Finished: Unit Tests"/>
</target>
<target name="testVarScoper" depends="prepare" description="Runs the varScoper">
<echo message="Starting: VarScoper Tests"/>
<!-- Save the results as a csv -->
<get dest="${test.varscoper.resultFile}" src="http://${test.host}:${test.port}${test.varscoper.base}/varScoper.cfm?displayformat=csv&filePath=${test.varscoper.filePath}&recursiveDirectory=${test.varscoper.recurse}"/>
<loadfile srcfile="${test.varscoper.resultFile}" property="test.varscoper.csv">
<filterchain>
<headfilter skip="1"/>
<trim/>
</filterchain>
</loadfile>
<!-- Remove the csv file -->
<delete file="${test.varscoper.resultFile}"/>
<!-- Fail the build if there are any violations of the var scoping -->
<fail message="Var Scope Violation:${line.separator}${test.varscoper.csv}">
<condition>
<isset property="test.varscoper.csv"/>
</condition>
</fail>
<echo message="Finished: VarScoper Tests"/>
</target>
<!-- Done in separate call since it required reading in updated property files -->
<target name="versionChanged">
<echo message="Starting: Version Changed" />
<property file="${basedir}/build/settings/project.properties"/>
<property file="${basedir}/build/settings/version.properties"/>
<!-- Combine the version parts into full version identifier -->
<property name="project.version" value="${project.version.major}.${project.version.minor}.${project.version.build}"/>
<!-- Update the version number for future development -->
<replaceregexp file="${project.key}/config/project.json.cfm"
match=""version": "[0-9\.]*""
replace=""version": "${project.version}""
byline="true"/>
<echo message="Finished: Version Changed"/>
</target>
<target name="versionNextMajor" description="Increment the version to the next major point number">
<echo message="Starting: Increment To Next Major Point"/>
<propertyfile file="${build}/settings/version.properties" comment="Version properties">
<entry key="project.version.major" value="1" operation="+" type="int"/>
<entry key="project.version.minor" value="0" type="int"/>
<entry key="project.version.build" value="0" type="int"/>
</propertyfile>
<antcall target="versionChanged" inheritall="false" inheritrefs="false"></antcall>
<echo message="Finished: Increment To Next Major Point"/>
</target>
<target name="versionNextMinor" description="Increment the version to the next minor point number">
<echo message="Starting: Increment To Next Minor Point"/>
<propertyfile file="${build}/settings/version.properties" comment="Version properties">
<entry key="project.version.minor" value="1" operation="+" type="int"/>
<entry key="project.version.build" value="0" type="int"/>
</propertyfile>
<antcall target="versionChanged" inheritall="false" inheritrefs="false"></antcall>
<echo message="Finished: Increment To Next Minor Point"/>
</target>
<macrodef name="git">
<attribute name="command" />
<attribute name="dir" default="" />
<element name="args" optional="true" />
<sequential>
<echo message="git @{command}" />
<exec executable="git" dir="@{dir}" failonerror="true">
<arg value="@{command}" />
<args/>
</exec>
</sequential>
</macrodef>
</project>