forked from PANmedia/raptor-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
389 lines (348 loc) · 15.7 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
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Raptor" default="build">
<if>
<not><equals arg1="${loaded}" arg2="true" /></not>
<then>
<property file="build/build.properties" override="false" />
</then>
</if>
<!-- =================================================================== -->
<!-- main build targets -->
<!-- =================================================================== -->
<target name="build">
<phingcall target="clean" />
<phingcall target="clone" />
<phingcall target="theme-build" />
<phingcall target="strip-blocks" />
<phingcall target="version" />
<phingcall target="combine" />
<phingcall target="compile" />
<phingcall target="merge" />
<phingcall target="merge-min" />
<phingcall target="package" />
</target>
<target name="test-build">
<echo>phing.project.name: ${phing.project.name}</echo>
<echo>project.basedir: ${project.basedir}</echo>
<echo>dir.package: ${dir.package}</echo>
<echo>dir.build: ${dir.build}</echo>
<echo>strip.blocks: ${strip.blocks}</echo>
<echo>theme: ${theme}</echo>
<echo>files.manifest: ${files.manifest}</echo>
<echo>jquery-no-conflict: ${jquery-no-conflict}</echo>
<echo>jquery-ui: ${jquery-ui}</echo>
<echo>jquery-ui-theme: ${jquery-ui-theme}</echo>
<echo>jquery-hotkeys: ${jquery-hotkeys}</echo>
<echo>rangy: ${rangy}</echo>
<echo>raptorize: ${raptorize}</echo>
<echo>wrapper: ${wrapper}</echo>
<echo>file.top: ${file.top}</echo>
</target>
<target name="0deps">
<property file="build/build.0deps.properties" override="true" />
<phingcall target="build" />
</target>
<target name="0depsnc">
<property file="build/build.0deps.nc.properties" override="true" />
<phingcall target="build" />
</target>
<target name="light">
<property file="build/build.light.properties" override="true" />
<phingcall target="build" />
</target>
<target name="debug">
<property file="build/build.debug.properties" override="true" />
<phingcall target="build" />
</target>
<!-- =================================================================== -->
<!-- Translation build targets -->
<!-- =================================================================== -->
<target name="translationcheck">
<translationcheck>
<fileset dir=".">
<include name="${dir.locales}/*.js" />
</fileset>
</translationcheck>
</target>
<target name="translationupdate">
<translationupdate>
<fileset dir=".">
<include name="${dir.locales}/*.js" />
</fileset>
</translationupdate>
</target>
<!-- =================================================================== -->
<!-- Compress PNG images -->
<!-- =================================================================== -->
<target name="pngout">
<foreach param="input.file.name" absparam="input.file" target="pngout-exec">
<fileset dir="src">
<include name="*.png" />
<include name="**/*.png" />
</fileset>
</foreach>
</target>
<!-- =================================================================== -->
<!-- Development build -->
<!-- =================================================================== -->
<target name="dev">
<phingcall target="clean" />
<phingcall target="dev-clone" />
<phingcall target="datauri" />
</target>
<target name="dev-clone">
<copy todir="${dir.build}" >
<fileset dir="src">
<include name="**/*" />
<exclude name="dependencies/**" />
</fileset>
</copy>
</target>
<!-- =================================================================== -->
<!-- Prepare for build -->
<!-- =================================================================== -->
<target name="clean">
<if>
<available file="${dir.build}" type="dir" />
<then>
<delete dir="${dir.build}" includeemptydirs="true" failonerror="true" />
</then>
</if>
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.package}" />
</target>
<target name="clone">
<clone file="${files.manifest}" builddir="${dir.build}" />
</target>
<target name="pngout-exec">
<exec command="pngout ${input.file}" logoutput="true" />
</target>
<!-- =================================================================== -->
<!-- Strip debug/strict blocks -->
<!-- =================================================================== -->
<target name="strip-blocks">
<echo>Stripping blocks ${strip.blocks}</echo>
<reflexive>
<fileset dir="${dir.build}">
<include pattern="**/*" />
</fileset>
<filterchain>
<!-- Replace the blocks using regex -->
<replaceregexp>
<regexp pattern="//\s<(${strip.blocks})>.*?//\s</(${strip.blocks})>"
replace="// <$1/>"
ignoreCase="true"
multiline="true" />
</replaceregexp>
</filterchain>
</reflexive>
</target>
<!-- =================================================================== -->
<!-- Replace version token with current version string -->
<!-- =================================================================== -->
<target name="version">
<echo>Replacing version token ${version}</echo>
<reflexive>
<fileset dir="${dir.build}">
<include pattern="**/*" />
</fileset>
<filterchain>
<!-- Replace the blocks using regex -->
<replaceregexp>
<regexp pattern="VERSION" replace="${version}" />
</replaceregexp>
</filterchain>
</reflexive>
</target>
<!-- =================================================================== -->
<!-- Compile theme -->
<!-- =================================================================== -->
<target name="theme">
<phingcall target="clean" />
<phingcall target="clone" />
<phingcall target="theme-build" />
</target>
<target name="theme-build">
<theme file="${files.manifest}" builddir="${dir.build}" />
<exec level="info" logOutput="true" dir="${dir.build}/src/style" command="
compass compile raptor.scss
" />
<copy file="${dir.build}/src/style/raptor.css" tofile="${project.basedir}/${dir.package}/raptor.css" />
<exec level="info" logOutput="true" command="
node node_modules/clean-css/bin/cleancss --output ${dir.package}/raptor.min.css ${dir.package}/raptor.css
" />
<exec level="info" logOutput="true" dir="${dir.build}/src/style" command="
compass compile front-end.scss
" />
<copy file="${dir.build}/src/style/front-end.css" tofile="${project.basedir}/${dir.package}/raptor-front-end.css" />
<exec level="info" logOutput="true" command="
node node_modules/clean-css/bin/cleancss --output ${dir.package}/raptor-front-end.min.css ${dir.package}/raptor-front-end.css
" />
</target>
<!-- =================================================================== -->
<!-- Convert images to data URIs -->
<!-- =================================================================== -->
<target name="datauri">
<datauri>
<fileset dir=".">
<include name="${dir.build}/*.css" />
<include name="${dir.build}/**/*.css" />
</fileset>
</datauri>
</target>
<!-- =================================================================== -->
<!-- Convert HTML templates to JSON -->
<!-- =================================================================== -->
<target name="template">
<template file="${files.manifest}" builddir="${dir.build}" />
</target>
<!-- =================================================================== -->
<!-- Combine all files -->
<!-- =================================================================== -->
<target name="combine" depends="datauri,template">
<combine file="${files.manifest}" builddir="${dir.build}" wrapper="${wrapper}" noconflict="${jquery-no-conflict}" />
</target>
<!-- =================================================================== -->
<!-- Compile (minify) all files -->
<!-- =================================================================== -->
<target name="compile">
<if>
<istrue value="${compile-js}" />
<then>
<exec dir="${phing.dir.raptor}" level="info" logoutput="true" command="
node node_modules/uglify-js/bin/uglifyjs -c -m --output ${dir.build}/concat.min.js ${dir.build}/concat.js
" />
</then>
<else>
<copy file="${dir.build}/concat.js" tofile="${dir.build}/concat.min.js" />
</else>
</if>
<if>
<istrue value="${compile-css}" />
<then>
<exec dir="${phing.dir.raptor}" level="info" logoutput="true" command="
node node_modules/clean-css/bin/cleancss --output ${dir.build}/concat.min.css ${dir.build}/concat.css
" />
</then>
<else>
<move file="${dir.build}/concat.css" tofile="${dir.build}/concat.min.css" />
</else>
</if>
</target>
<!-- =================================================================== -->
<!-- Merge CSS and JS into one file -->
<!-- =================================================================== -->
<target name="merge">
<php>file_put_contents('${dir.build}/merge.js', file_get_contents('${file.top}'));</php>
<!-- Append the merged JS -->
<append destFile="${dir.build}/merge.js">
<fileset dir=".">
<include name="${dir.build}/concat.js" />
</fileset>
</append>
<!-- Append the style inserter -->
<echo file="${dir.build}/merge.js" append="true"><![CDATA[document.write('<style type="text/css">]]></echo>
<reflexive>
<fileset dir="${dir.build}">
<include pattern="concat.css" />
</fileset>
<filterchain>
<!-- Escape quotes -->
<replaceregexp>
<regexp pattern="'" replace="\'" />
<regexp pattern="\r" replace="" />
<regexp pattern="\n" replace="\n\${line.separator}" />
</replaceregexp>
</filterchain>
</reflexive>
<append destFile="${dir.build}/merge.js">
<fileset dir=".">
<include name="${dir.build}/concat.css" />
</fileset>
</append>
<echo file="${dir.build}/merge.js" append="true"><![CDATA[</style>');]]></echo>
</target>
<target name="merge-min">
<php>file_put_contents('${dir.build}/merge.min.js', file_get_contents('${file.top}'));</php>
<!-- Append the merged JS -->
<append destFile="${dir.build}/merge.min.js">
<fileset dir=".">
<include name="${dir.build}/concat.min.js" />
</fileset>
</append>
<!-- Append the style inserter -->
<echo file="${dir.build}/merge.min.js" append="true"><![CDATA[document.write('<style type="text/css">]]></echo>
<reflexive>
<fileset dir="${dir.build}">
<include pattern="concat.min.css" />
</fileset>
<filterchain>
<!-- Escape quotes -->
<replaceregexp>
<regexp pattern="'" replace="\'" />
<regexp pattern="\n" replace="\n\${line.separator}" />
</replaceregexp>
</filterchain>
</reflexive>
<append destFile="${dir.build}/merge.min.js">
<fileset dir=".">
<include name="${dir.build}/concat.min.css" />
</fileset>
</append>
<echo file="${dir.build}/merge.min.js" append="true"><![CDATA[</style>');]]></echo>
</target>
<!-- =================================================================== -->
<!-- Package files -->
<!-- =================================================================== -->
<target name="package">
<mkdir dir="${dir.package}" />
<copy file="${dir.build}/merge.js" tofile="${dir.package}/${filename}.js" />
<echo>${dir.package}/${filename}.js</echo>
<copy file="${dir.build}/merge.min.js" tofile="${dir.package}/${filename}.min.js" />
<echo>${dir.package}/${filename}.min.js</echo>
</target>
<!-- =================================================================== -->
<!-- Test scss -->
<!-- =================================================================== -->
<target name="test-css">
<exec level="info" logOutput="true" dir="tests" command="
bundle exec sass --compass scss/case.scss css/case.css
" />
<exec level="info" logOutput="true" dir="tests" command="
bundle exec sass --compass scss/diff.scss css/diff.css
" />
<exec level="info" logOutput="true" dir="tests" command="
bundle exec sass --compass scss/style.scss css/style.css
" />
<exec level="info" logOutput="true" dir="tests" command="
bundle exec sass --compass scss/table.scss css/style.css
" />
<exec level="info" logOutput="true" dir="tests" command="
bundle exec sass --compass scss/tests.scss css/tests.css
" />
</target>
<!-- =================================================================== -->
<!-- Adhoc classes -->
<!-- =================================================================== -->
<adhoc-task name="datauri">
require_once '${project.basedir}/classes/DataURI.php';
</adhoc-task>
<adhoc-task name="template">
require_once '${project.basedir}/classes/TemplateTask.php';
</adhoc-task>
<adhoc-task name="translationcheck">
require_once '${project.basedir}/classes/TranslationCheckTask.php';
</adhoc-task>
<adhoc-task name="translationupdate">
require_once '${project.basedir}/classes/TranslationUpdateTask.php';
</adhoc-task>
<adhoc-task name="combine">
require_once '${project.basedir}/classes/CombineTask.php';
</adhoc-task>
<adhoc-task name="clone">
require_once '${project.basedir}/classes/CloneTask.php';
</adhoc-task>
<adhoc-task name="theme">
require_once '${project.basedir}/classes/ThemeTask.php';
</adhoc-task>
</project>