-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
405 lines (341 loc) · 15 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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<?xml version="1.0" encoding="UTF-8"?>
<project name="JCar" default="help" basedir=".">
<property file="build.properties"/>
<property name="path.administrator" value="${path.joomla}/administrator"/>
<property name="path.administrator.components" value="${path.administrator}/components"/>
<property name="path.administrator.languages" value="${path.administrator}/language"/>
<property name="path.components" value="${path.joomla}/components"/>
<property name="path.languages" value="${path.joomla}/language"/>
<property name="path.media" value="${path.joomla}/media"/>
<property name="path.plugins" value="${path.joomla}/plugins"/>
<property name="path.modules" value="${path.joomla}/modules"/>
<property name="path.libs" value="${path.joomla}/libraries"/>
<property name="path.cli" value="${path.joomla}/cli"/>
<property name="package.dest" value="${src}/build"/>
<property name="extensions" value="components,libraries,modules,plugins"/>
<target name="deploy" description="Updates existing extensions in a Joomla! site.">
<foreach list="${extensions}" param="extension" target="deploy_extensions"/>
</target>
<target name="deploy_extensions" hidden="true">
<if>
<available file="${extension}" type="dir"/>
<then>
<foreach param="directory" absparam="path" target="deploy_extension">
<fileset dir="${extension}">
<type type="dir"/>
<depth max="0" min="0"/>
</fileset>
</foreach>
</then>
</if>
</target>
<target name="deploy_extension" hidden="true">
<switch value="${path}">
<case value="components/${directory}">
<phingcall target="deploy_component"/>
</case>
<case value="libraries/${directory}">
<phingcall target="deploy_library"/>
</case>
<case value="modules/${directory}">
<phingcall target="deploy_module"/>
</case>
<case value="plugins/${directory}">
<phingcall target="deploy_plugins"/>
</case>
<!-- windows \ variations -->
<case value="components\${directory}">
<phingcall target="deploy_component"/>
</case>
<case value="libraries\${directory}">
<phingcall target="deploy_library"/>
</case>
<case value="modules\${directory}">
<phingcall target="deploy_module"/>
</case>
<case value="plugins\${directory}">
<phingcall target="deploy_plugins"/>
</case>
<default/>
</switch>
</target>
<target name="deploy_component" hidden="true">
<if>
<available file="${path.components}/${directory}" type="dir"/>
<then>
<delete includeemptydirs="false">
<fileset dir="${path.components}/${directory}" includes="**/*"/>
<fileset dir="${path.administrator.components}/${directory}" includes="**/*"/>
<fileset dir="${path.media}/${directory}" includes="**/*"/>
</delete>
<copy todir="${path.components}/${directory}">
<fileset dir="./components/${directory}/site">
<include name="**/**"/>
<exclude name="language/**"/>
</fileset>
</copy>
<copy todir="${path.languages}">
<fileset dir="components/${directory}/site/language">
<include name="**/**"/>
</fileset>
</copy>
<copy todir="${path.administrator.components}/${directory}">
<fileset dir="components/${directory}/admin">
<exclude name="cli/**"/>
<exclude name="language/**"/>
<include name="**/**"/>
</fileset>
<fileset dir="components/${directory}">
<include name="*.xml"/>
</fileset>
</copy>
<copy todir="${path.administrator.languages}">
<fileset dir="components/${directory}/admin/language">
<include name="**/**"/>
</fileset>
</copy>
<if>
<available file='components/${directory}/admin/cli' type='dir'/>
<then>
<copy todir="${path.cli}">
<fileset dir="./components/${directory}/admin/cli">
<include name="*"/>
</fileset>
</copy>
</then>
</if>
<if>
<available file='${src}/components/${directory}/media' type='dir'/>
<then>
<mkdir dir="${path.media}/${directory}"/>
<copy todir="${path.media}/${directory}">
<fileset dir="./components/${directory}/media/">
<include name="**/**"/>
</fileset>
</copy>
</then>
</if>
</then>
</if>
</target>
<target name="deploy_library" hidden="true">
<if>
<available file="${path.libs}/${directory}" type="dir"/>
<then>
<delete includeemptydirs="false">
<fileset dir="${path.libs}/${directory}" includes="**/*"/>
</delete>
<copy todir="${path.libs}/${directory}">
<fileset dir="./libraries/${directory}">
<include name="**/**"/>
<exclude name="language/**"/>
</fileset>
</copy>
<copy todir="${path.languages}">
<fileset dir="./libraries/${directory}/language">
<include name="**/**"/>
</fileset>
</copy>
<copy todir="${path.administrator.languages}">
<fileset dir="./libraries/${directory}/language">
<include name="**/**"/>
</fileset>
</copy>
<copy todir="${path.administrator}/manifests">
<fileset dir="libraries/${directory}">
<include name="*.xml"/>
</fileset>
</copy>
</then>
</if>
</target>
<target name="deploy_module" hidden="true">
<if>
<available file="${path.modules}/${directory}" type="dir"/>
<then>
<delete includeemptydirs="false">
<fileset dir="${path.modules}/${directory}" includes="**/*"/>
</delete>
<copy todir="${path.modules}/${directory}">
<fileset dir="./modules/${directory}">
<include name="**/**"/>
<exclude name="language/**"/>
</fileset>
</copy>
<copy todir="${path.languages}">
<fileset dir="./modules/${directory}/language">
<include name="**/**"/>
</fileset>
</copy>
</then>
</if>
</target>
<target name="deploy_plugins" hidden="true">
<if>
<available file="${extension}" type="dir"/>
<then>
<foreach param="subdirectory" absparam="plugin_path" target="deploy_plugin">
<fileset dir="plugins/${directory}">
<type type="dir"/>
<depth max="0" min="0"/>
</fileset>
</foreach>
</then>
</if>
</target>
<target name="deploy_plugin" hidden="true">
<if>
<available file="${path.plugins}/${directory}/${subdirectory}" type="dir"/>
<then>
<delete includeemptydirs="false">
<fileset dir="${path.plugins}/${directory}/${subdirectory}" includes="**/*"/>
</delete>
<copy todir="${path.plugins}/${directory}/${subdirectory}">
<fileset dir="${src}/plugins/${directory}/${subdirectory}">
<include name="**/**"/>
<exclude name="language/**"/>
</fileset>
</copy>
<copy todir="${path.administrator.languages}">
<fileset dir="${src}/plugins/${directory}/${subdirectory}/language">
<include name="**/**"/>
</fileset>
</copy>
</then>
</if>
</target>
<target name="test" description="Runs all unit tests." depends="deploy, deploy_test_data">
<phpunit bootstrap="tests/unit/bootstrap.php">
<formatter type="plain" usefile="false"/>
<batchtest>
<fileset dir="tests/unit/suites/libraries/JSpace/Metadata">
<include name="*Test.php"/>
</fileset>
<fileset dir="tests/unit/suites/plugins/${id}">
<include name="harvest/*Test.php"/>
<include name="localstore/*Test.php"/>
<include name="weblinks/*Test.php"/>
<!-- it would be good to run the individual harvesting tests but something is causing the oai tests to fail. Most probably caused by both plugins being loaded. Would be good to have better control over loading and testing plugins. -->
<exclude name="oai/*Test.php"/>
<exclude name="opensearch/*Test.php"/>
</fileset>
</batchtest>
</phpunit>
</target>
<target name="deploy_test_data">
<delete includeemptydirs="false">
<fileset dir="${path.joomla}/../${id}" includes="**/*"/>
</delete>
<copy todir="${path.joomla}/../${id}">
<fileset dir="tests/unit/stubs">
<include name="**/**"/>
</fileset>
</copy>
<move
file="${path.joomla}/../${id}/opensearch/htaccess.txt"
tofile="${path.joomla}/../${id}/opensearch/.htaccess"/>
</target>
<target name="cpd" description="Check for copying and pasting.">
<phpcpd minTokens="50">
<fileset dir="${src}">
<include name="**/*.php"/>
<exclude name="tests/**"/>
</fileset>
</phpcpd>
</target>
<target name="package" description="Packages extensions ready for installation into Joomla!.">
<mkdir dir="${package.dest}"/>
<foreach list="${extensions}" param="extension" target="package_extensions"/>
<move todir="${package.dest}/packages">
<fileset dir="${package.dest}" includes="${package.extensions}"/>
</move>
<zip destfile="${package.dest}/pkg_${id}.zip">
<fileset dir="${package.dest}">
<include name="packages/**"/>
</fileset>
<fileset dir=".">
<include name="pkg_jcar.xml"/>
</fileset>
</zip>
<delete dir="${package.dest}/packages"/>
</target>
<target name="package_extensions" hidden="true">
<if>
<available file="${extension}" type="dir"/>
<then>
<foreach param="directory" absparam="path" target="package_extension">
<fileset dir="${extension}">
<type type="dir"/>
<depth max="0" min="0"/>
</fileset>
</foreach>
</then>
</if>
</target>
<target name="package_extension" hidden="true">
<switch value="${path}">
<case value="plugins/${directory}">
<foreach param="subdirectory" absparam="plugin_path" target="package_plugin">
<fileset dir="plugins/${directory}">
<type type="dir"/>
<depth max="0" min="0"/>
</fileset>
</foreach>
</case>
<default>
<zip
destfile="${package.dest}/${directory}.zip"
basedir="${src}/${extension}/${directory}"/>
</default>
</switch>
</target>
<target name="package_plugin" hidden="true">
<php function="str_replace" returnProperty="replaced">
<param value="plugins"/>
<param value="plg"/>
<param value="${plugin_path}"/>
</php>
<php function="str_replace" returnProperty="replaced">
<param value="/"/>
<param value="_"/>
<param value="${replaced}"/>
</php>
<zip
destfile="${package.dest}/${replaced}.zip"
basedir="${src}/${plugin_path}"/>
</target>
<target name="setup_properties" hidden="true">
<tstamp>
<format property="build.date" pattern="%Y-%m-%d" />
</tstamp>
<!-- @TODO automate version. -->
</target>
<target name="help" description="Help documentation for this build file.">
<echo message="JCar for Joomla!"/>
<echo message="Targets:"/>
<echo message="cpd Check for copy/paste code duplication."/>
<echo message=""/>
<echo message="deploy Copy extension code to an existing Joomla"/>
<echo message=" installation as defined by the dest"/>
<echo message=" parameter in your build.properties file."/>
<echo message=""/>
<echo message="package Packages all extensions for installation"/>
<echo message=" via the Joomla Extension Manager."/>
<echo message=""/>
<echo message="test Run the unit tests."/>
<echo message=""/>
<echo message="Additional Flags:"/>
<echo message=""/>
<echo message="extensions Specify one or more extension types to"/>
<echo message=" target when calling deploy or package."/>
<echo message=" Available options are:"/>
<echo message=" - components"/>
<echo message=" - libraries"/>
<echo message=" - modules"/>
<echo message=" - plugins"/>
<echo message="Examples:"/>
<echo message=""/>
<echo message="phing deploy -Dextensions=plugins"/>
<echo message="phing package -Dextensions=components"/>
</target>
</project>