This repository was archived by the owner on Sep 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
332 lines (293 loc) · 9.86 KB
/
build.xml
File metadata and controls
332 lines (293 loc) · 9.86 KB
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<project name="ResearchHighlights" default="quick" basedir=".">
<description>
Build file for the Research Highlights website
</description>
<!-- DIRECTORIES -->
<property name="dist.dir" location="dist"/>
<property name="dist.web.css.dir" location="dist/web/css"/>
<property name="dist.sys.css.dir" location="dist/sys/css"/>
<property name="dist.web.js.dir" location="dist/web/js"/>
<property name="dist.sys.js.dir" location="dist/sys/js"/>
<property name="lib.dir" location="lib"/>
<property name="src.dir" location="src"/>
<property name="src_private.dir" location="src_private"/>
<!-- YUI COMPRESSOR JAR -->
<property name="yui-compressor.jar" location="${lib.dir}/yuicompressor-2.4.8.jar"/>
<!-- PARAMETERS REQUIRED FOR BUILD -->
<condition property="params.addr.set" else="false">
<and>
<isset property="path"/>
<isset property="domain"/>
</and>
</condition>
<!-- ANT TASK DEFINITIONS -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${lib.dir}/ant-contrib.jar"/>
</classpath>
</taskdef>
<!-- ANT TARGETS -->
<target name="clean" description="Remove built and temporary files" >
<echo message="Removing previous build"/>
<delete dir="${dist.dir}"/>
</target>
<target name="build" depends="clean" description="Create the website">
<tstamp/>
<echo message="Creating ${dist.dir}"/>
<mkdir dir="${dist.dir}"/>
<echo message="Copying sources from ${src.dir} to ${dist.dir}"/>
<copy todir="${dist.dir}" >
<fileset dir="${src.dir}" includes="**"/>
</copy>
<if>
<available file="${src_private.dir}" type="dir" />
<then>
<echo message="Copying sources from ${src_private.dir} to ${dist.dir}"/>
<copy todir="${dist.dir}" overwrite="true">
<fileset dir="${src_private.dir}" includes="**"/>
</copy>
</then>
</if>
<echo message="Replacing constants in all files, based on configuration"/>
<loadfile property="config.file" srcfile="${dist.dir}/config.php"/>
<if>
<and>
<isset property="domain"/>
<isset property="path"/>
</and>
<then>
<echo message="Setting the DOMAIN and PATH in configuration file"/>
<replace file="${dist.dir}/config.php" token="@@@DOMAIN@@@" value="${domain}"/>
<replace file="${dist.dir}/config.php" token="@@@PATH@@@" value="${path}"/>
</then>
<else>
<propertyregex property="domain" input="${config.file}" regexp="\\define\('DOMAIN', '([@a-zA-Z\:./_-]*)'" select="\1" />
<antcall target="set-const">
<param name="const" value="DOMAIN"/>
<param name="val" value="${domain}"/>
<param name="config" value="true"/>
</antcall>
<propertyregex property="path" input="${config.file}" regexp="\\define\('PATH', '([@a-zA-Z\:./_-]*)'" select="\1" />
<antcall target="set-const">
<param name="const" value="PATH"/>
<param name="val" value="${path}"/>
<param name="config" value="true"/>
</antcall>
</else>
</if>
<!-- SET URI_NICE -->
<if>
<isset property="niceUri"/>
<then>
<echo message="Setting the NICE_URI in configuration file"/>
<replace file="${dist.dir}/config.php" token="@@@URI_NICE@@@" value="${niceUri}"/>
</then>
<else>
<replace file="${dist.dir}/config.php" token="@@@URI_NICE@@@" value="${domain}${path}"/>
</else>
</if>
<propertyregex property="uri_nice" input="${config.file}" regexp="\\define\('URI_NICE', '(.*)'" select="\1" />
<antcall target="set-const">
<param name="const" value="URI_NICE"/>
<param name="val" value="${uri_nice}"/>
<param name="files" value="**/*"/>
</antcall>
<!-- SET SYS_HTAC -->
<if>
<not>
<isset property="sysHtaccess"/>
</not>
<then>
<propertyregex property="sysHtaccess" input="${config.file}" regexp="\\define\('SYS_HTAC', ([@a-zA-Z\:./_-]*)" select="\1" />
</then>
</if>
<antcall target="set-const">
<param name="const" value="SYS_HTAC"/>
<param name="val" value="${sysHtaccess}"/>
<param name="files" value="**/*"/>
<param name="config" value="true"/>
</antcall>
<!-- SET URI_ROOT -->
<if>
<equals arg1="${sysHtaccess}" arg2="true"/>
<then>
<property name="uriRoot" value="${domain}${path}"/>
</then>
<else>
<property name="uriRoot" value="${domain}${path}/index.php"/>
</else>
</if>
<!-- SET EMAIL -->
<if>
<not>
<isset property="email"/>
</not>
<then>
<propertyregex property="email" input="${config.file}" regexp="\\define\('EMAIL', '([@a-zA-Z\:./_-]*)'" select="\1" />
</then>
</if>
<antcall target="set-const">
<param name="const" value="EMAIL"/>
<param name="val" value="${email}"/>
<param name="files" value="**/*"/>
</antcall>
<!-- SET SITE_NAME -->
<propertyregex property="site_name" input="${config.file}" regexp="\\define\('SITE_NAME', '(.*)'" select="\1" />
<antcall target="set-const">
<param name="const" value="SITE_NAME"/>
<param name="val" value="${site_name}"/>
<param name="files" value="**/*"/>
</antcall>
<!-- SET TITLE -->
<propertyregex property="title" input="${config.file}" regexp="\\define\('TITLE', '(.*)'" select="\1" />
<antcall target="set-const">
<param name="const" value="TITLE"/>
<param name="val" value="${title}"/>
<param name="files" value="**/*"/>
</antcall>
<!-- SET TITLE_SEP -->
<propertyregex property="title_sep" input="${config.file}" regexp="\\define\('TITLE_SEP', '(.*)'" select="\1" />
<antcall target="set-const">
<param name="const" value="TITLE_SEP"/>
<param name="val" value="${title_sep}"/>
<param name="files" value="**/*"/>
</antcall>
<!-- RECURSIVELY APPLY CHANGES THROUGH STATIC FILES -->
<antcall target="set-const">
<param name="const" value="DOMAIN"/>
<param name="val" value="${domain}"/>
<param name="files" value="**/*"/>
</antcall>
<antcall target="set-const">
<param name="const" value="PATH"/>
<param name="val" value="${path}"/>
<param name="files" value="**/*"/>
</antcall>
<antcall target="set-const">
<param name="const" value="HOME"/>
<param name="val" value="${domain}${path}"/>
<param name="files" value="**/*"/>
</antcall>
<antcall target="set-const">
<param name="const" value="URI_ROOT"/>
<param name="val" value="${uriRoot}"/>
<param name="files" value="**/*"/>
</antcall>
</target>
<target name="quick" depends="clean,build" description="Create the website">
<antcall target="set-const">
<param name="const" value="EXT_JS"/>
<param name="val" value=".js"/>
<param name="config" value="true"/>
<param name="files" value="**/*"/>
</antcall>
<antcall target="set-const">
<param name="const" value="EXT_CSS"/>
<param name="val" value=".css"/>
<param name="config" value="true"/>
<param name="files" value="**/*"/>
</antcall>
</target>
<!-- COMPRESSION TASKS -->
<target name="full" depends="clean,build" description="Compress JavaScript and CSS files">
<antcall target="compress-js">
<param name="dir" value="${dist.sys.js.dir}"/>
</antcall>
<antcall target="compress-js">
<param name="dir" value="${dist.web.js.dir}"/>
</antcall>
<antcall target="set-const">
<param name="const" value="EXT_JS"/>
<param name="val" value=".min.js"/>
<param name="config" value="true"/>
<param name="files" value="**/*"/>
</antcall>
<property name="css.ext" location=".min.css"/>
<antcall target="compress-css">
<param name="dir" value="${dist.sys.css.dir}"/>
</antcall>
<antcall target="compress-css">
<param name="dir" value="${dist.web.css.dir}"/>
</antcall>
<antcall target="set-const">
<param name="const" value="EXT_CSS"/>
<param name="val" value=".min.css"/>
<param name="config" value="true"/>
<param name="files" value="**/*"/>
</antcall>
</target>
<target name="compress-js" description="Compress JavaScript files">
<fail message="Must provide the JS directory with dir parameter">
<condition>
<not>
<isset property="dir"/>
</not>
</condition>
</fail>
<echo message="Compressing JS files in ${dir}"/>
<apply executable="java" dest="${dir}" parallel="false" verbose="true" ignoremissing="true">
<fileset dir="${dir}" includes="**/*.js" excludes="**/*.min.js"/>
<arg line="-jar"/>
<arg path="${yui-compressor.jar}"/>
<arg line="-o"/>
<mapper type="glob" from="*.js" to="*.min.js"/>
<targetfile/>
<srcfile/>
</apply>
</target>
<target name="compress-css" description="Compress CSS files">
<fail message="Must provide the CSS directory with dir parameter">
<condition>
<not>
<isset property="dir"/>
</not>
</condition>
</fail>
<echo message="Compressing CSS files in ${dir}"/>
<apply executable="java" dest="${dir}" parallel="false" verbose="true" ignoremissing="true">
<fileset dir="${dir}" includes="**/*.css" excludes="**/*.min.css"/>
<arg line="-jar"/>
<arg path="${yui-compressor.jar}"/>
<arg line="-o"/>
<mapper type="glob" from="*.css" to="*.min.css"/>
<targetfile/>
<srcfile/>
</apply>
</target>
<!-- UTILITY TARGETS -->
<target name="set-const" description="Set a configuration constant">
<fail message="Must provide the constant, current value and new value">
<condition>
<not>
<or>
<isset property="const"/>
<isset property="val"/>
</or>
</not>
</condition>
</fail>
<echo message="Set ${const} to ${val}"/>
<if>
<and>
<isset property="config"/>
<istrue value="${config}"/>
</and>
<then>
<echo message="Apply change in ${dist.dir}/config.php"/>
<replaceregexp file="${dist.dir}/config.php" flags="gs">
<regexp pattern="\\define\('${const}', '([@a-zA-Z\:./_-]*)'"/>
<substitution expression="\\define\('${const}', '${val}'"/>
</replaceregexp>
</then>
</if>
<if>
<isset property="files"/>
<then>
<echo message="Replace @@@${const}@@@ in ${files}"/>
<replace dir="${dist.dir}" token="@@@${const}@@@" value="${val}">
<include name="${files}"/>
</replace>
</then>
</if>
</target>
</project>