-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.xml
647 lines (527 loc) · 18.8 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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
<?xml version="1.0" encoding="UTF-8"?>
<!--
xmlstarlet is required to run this build script
Ubuntu/Debian: apt-get install xmlstarlet
CentOS/RHEL: yum install xmlstarlet
-->
<project name="jmmldap-2" basedir="." default="main">
<property name="package" value="jmmldap" override="true" />
<property name="script.dir" value="./_build/scripts" override="false" />
<property name="template.dir" value="./_build/template" override="false" />
<property name="updates.dir" value="./_build/updates" override="false" />
<property name="package.manifest" value="${template.dir}" override="false" />
<property name="package.version" value="2.0.0.trunk" override="false" />
<property name="package.dest" value="./_build/${package.version}" override="false" />
<tstamp>
<format property="DATE" pattern="%c" locale="en_GB" />
</tstamp>
<!--
Usage:
1. Standard build
$ phing
2. Build and rename files with version
$ phing -Dpackage.version=1.0.1
-->
<target name="main" description="">
<echo message="Building JMapMyLDAP Version ${package.version} packages..." />
<!-- Cleanup build area -->
<if>
<available file="${package.dest}" type="dir" />
<then>
<delete dir="${package.dest}" />
</then>
</if>
<mkdir dir="${package.dest}" />
<mkdir dir="${package.dest}/packages" />
<phingcall target="build">
<property name="extension.path" value="modules/mod_shldap_login" />
<property name="manifest" value="mod_shldap_login.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/authentication/shadapter" />
<property name="manifest" value="shadapter.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/system/shplatform" />
<property name="manifest" value="shplatform.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/ldap/creation" />
<property name="manifest" value="creation.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/ldap/deletion" />
<property name="manifest" value="deletion.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/ldap/injection" />
<property name="manifest" value="injection.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/ldap/mapping" />
<property name="manifest" value="mapping.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/ldap/password" />
<property name="manifest" value="password.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/ldap/profile" />
<property name="manifest" value="profile.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/shlog/ldap" />
<property name="manifest" value="ldap.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/shlog/sso" />
<property name="manifest" value="sso.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/sso/http" />
<property name="manifest" value="http.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/sso/dummy" />
<property name="manifest" value="dummy.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="plugins/sso/edirldap" />
<property name="manifest" value="edirldap.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="libraries/shmanic" />
<property name="extension.name" value="lib_shmanic" />
<property name="manifest" value="lib_shmanic.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="cli" />
<property name="manifest" value="cli_shmanic_ldap.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="administrator/components/com_shconfig" />
<property name="manifest" value="shconfig.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="build">
<property name="extension.path" value="administrator/components/com_shldap" />
<property name="manifest" value="shldap.xml" />
<property name="manifest.use" value="1" />
</phingcall>
<phingcall target="package">
<property name="manifest" value="pkg_shplatform.xml" />
</phingcall>
<phingcall target="package">
<property name="manifest" value="pkg_ldap_core.xml" />
</phingcall>
<phingcall target="package">
<property name="manifest" value="pkg_ldap_sso_core.xml" />
</phingcall>
<phingcall target="package">
<property name="manifest" value="pkg_ldap_plugins.xml" />
</phingcall>
<phingcall target="package">
<property name="manifest" value="pkg_shautoupdater.xml" />
</phingcall>
<phingcall target="updates" />
<phingcall target="zipall" />
<echo message="Package export directory ${package.dest}/packages" />
</target>
<target name="zipall">
<!-- Also make a Zip of everything called UNZIPFIRST.zip -->
<zip destfile="${package.dest}/packages/UNZIPFIRST.zip" basedir="${package.dest}/packages">
<fileset dir="${package.dest}/packages">
<include name="**" />
<exclude name=".*" />
<exclude name="*.tar.gz" />
</fileset>
</zip>
</target>
<target name="updates" description="Updates the update manifests.">
<property name="updates.dest" value="${package.dest}/updates" />
<!-- Check if the target folder exists. If not, create it -->
<if>
<not>
<available file="${updates.dest}" type="dir" />
</not>
<then>
<mkdir dir="${updates.dest}" />
</then>
</if>
<copy todir="${updates.dest}">
<!-- Copy the source files to the target folder -->
<fileset dir="${updates.dir}">
<include name="**" />
<exclude name=".*" />
</fileset>
</copy>
<foreach param="file.xml" absparam="absname" target="updates:updateXml">
<fileset dir="${updates.dest}">
<type type="file" />
</fileset>
</foreach>
</target>
<target name="updates:updateXml">
<if>
<isset property="file.xml" />
<then>
<!-- TODO put in native PHP script to do this - use xmlstarlet for now -->
<property name="path.xml" value="${updates.dest}/${file.xml}" />
<echo msg="xmlstarlet ed -P -L -u '/extensionset/extension/@version' --value '${package.version}' '${path.xml}'" />
<exec command="xmlstarlet ed -P -L -u '/extensionset/extension/@version' --value '${package.version}' '${path.xml}'" checkreturn="false" />
</then>
</if>
</target>
<target name="package" description="Creates several packages after the build to package packages.">
<property name="manifest.source" value="${template.dir}/${manifest}" />
<xmlproperty file="${manifest.source}" collapseAttributes="true" />
<property name="extension.dest" value="${package.dest}/pkg_${extension.packagename}" />
<!-- Check if the target folder exists. If not, create it -->
<if>
<not>
<available file="${extension.dest}" type="dir" />
</not>
<then>
<mkdir dir="${extension.dest}" />
</then>
</if>
<property name="manifest.dest" value="${extension.dest}/${manifest}" />
<copy file="${manifest.source}" tofile="${manifest.dest}" overwrite="true" />
<phingcall target="prep:updateXml">
<property name="path.xml" value="${manifest.dest}" override="true" />
</phingcall>
<foreach list="${extension.files.file}" param="filename" target="prep:copyFiles">
<property name="extension.path" value="${package.dest}/packages" override="true" />
</foreach>
<!-- Add the scriptfile to the extension -->
<if>
<isset property="extension.scriptfile" />
<then>
<echo message="Adding install script ${extension.scriptfile}" />
<copy file="${script.dir}/${extension.scriptfile}" tofile="${extension.dest}/${extension.scriptfile}" overwrite="true" />
</then>
</if>
<if>
<isset property="extension.languages.language" />
<then>
<!-- Create the lang/en-GB strucutre for now until we have sorted out these XMLs -->
<if>
<available file="${extension.dest}/language" type="dir" />
<then>
<delete dir="${extension.dest}/language" />
</then>
</if>
<!-- TODO fix this - or just add as we go along -->
<mkdir dir="${extension.dest}/language" />
<mkdir dir="${extension.dest}/language/en-GB" />
<foreach list="${extension.languages.language}" param="lang" target="prep:copyLang" />
</then>
</if>
<!-- Switch to tell this task to make the zip files. Default is on. -->
<if>
<not>
<isset property="build.compress" />
</not>
<then>
<property name="build.compress" value="1" />
</then>
</if>
<!-- Start the compress if specified -->
<if>
<equals arg1="${build.compress}" arg2="1" />
<then>
<phingcall target="build:compress">
<property name="extension.name" value="pkg_${extension.packagename}" override="true" />
</phingcall>
</then>
</if>
</target>
<target name="build" description="Packages the extension for delivery." depends="prep">
<echo message="Building Package ${extension.name}" />
<!-- Switch to tell this task to make the zip files. Default is on. -->
<if>
<not>
<isset property="build.compress" />
</not>
<then>
<property name="build.compress" value="1" />
</then>
</if>
<!-- Start the compress if specified -->
<if>
<equals arg1="${build.compress}" arg2="1" />
<then>
<phingcall target="build:compress">
<property name="extension.name" value="${extension.name}" override="true" />
</phingcall>
</then>
</if>
</target>
<target name="prep" description="Copies the extension file and directories to the package destination.">
<!-- The following options are for picking up the right files/folders. -->
<if>
<not>
<isset property="manifest" />
</not>
<then>
<property name="manifest" value="${extension.name}.xml" />
</then>
</if>
<property name="manifest.source" value="${extension.path}/${manifest}" />
<!-- Use the Manifest file to populate extension.* -->
<if>
<equals arg1="${manifest.use}" arg2="1" />
<then>
<xmlproperty file="${manifest.source}" collapseAttributes="true" />
</then>
</if>
<property name="extension.dest" value="${package.dest}/${extension.name}" override="true" />
<property name="manifest.dest" value="${extension.dest}/${manifest}" />
<!-- Check if the target folder exists. If not, create it -->
<if>
<not>
<available file="${extension.dest}" type="dir" />
</not>
<then>
<mkdir dir="${extension.dest}" />
</then>
</if>
<if>
<or>
<isset property="extension.build.folder" />
<isset property="extension.build.filename" />
</or>
<then>
<echo message="Folders: ${extension.build.folder}" />
<echo message="File: ${extension.build.filename}" />
<!-- Copy folders and files one by one -->
<if>
<isset property="extension.build.folder" />
<then>
<foreach list="${extension.build.folder}" param="folder" target="prep:createFolder" />
</then>
</if>
<if>
<isset property="extension.build.filename" />
<then>
<foreach list="${extension.build.filename}" param="filename" target="prep:copyFiles" />
</then>
</if>
</then>
<else>
<copy todir="${extension.dest}">
<!-- Copy the source files to the target folder -->
<fileset dir="${extension.path}">
<include name="**" />
<exclude name=".*" />
<exclude name="index.html" />
<exclude name="LICENSE.txt" />
</fileset>
</copy>
</else>
</if>
<!-- Add the scriptfile to the extension -->
<if>
<isset property="extension.scriptfile" />
<then>
<echo message="Adding install script ${extension.scriptfile}" />
<copy file="${script.dir}/${extension.scriptfile}" tofile="${extension.dest}/${extension.scriptfile}" overwrite="true" />
</then>
</if>
<copy todir="${extension.dest}">
<!-- Copy the index and license template files to the target folder -->
<fileset dir="${template.dir}">
<include name="LICENSE.txt" />
<include name="index.html" />
</fileset>
</copy>
<!-- Puts index.html in all subdirs -->
<foreach param="path.dir" absparam="absname" target="prep:copyIndex">
<fileset dir="${extension.dest}">
<type type="dir" />
<depth max="20" min="0" />
</fileset>
</foreach>
<phingcall target="prep:updateXml">
<property name="path.xml" value="${extension.dest}/${manifest}" override="true" />
</phingcall>
<!-- REMOVE IF NOT USED -->
<if>
<equals arg1="${extension.type}" arg2="component" />
<then>
<if>
<available file="${extension.dest}/sql/updates/mysql" type="dir" />
<then>
<echo message="Touch the update SQL so to ensure no errors on update" />
<touch file="${extension.dest}/sql/updates/mysql/${package.version}.sql" />
</then>
</if>
</then>
<elseif>
<equals arg1="${extension.type}" arg2="library" />
<then>
<echo message="Library" />
</then>
</elseif>
</if>
<!-- Due to having multiple locations for the language XML, we need to provide it to a tmp variable -->
<if>
<isset property="extension.languages.language" />
<then>
<property name="temp.languages" value="${extension.languages.language}" />
</then>
<elseif>
<isset property="extension.administration.languages.language" />
<then>
<property name="temp.languages" value="${extension.administration.languages.language}" />
</then>
</elseif>
</if>
<if>
<isset property="temp.languages" />
<then>
<!-- Create the lang/en-GB strucutre for now until we have sorted out these XMLs -->
<if>
<available file="${extension.dest}/language" type="dir" />
<then>
<delete dir="${extension.dest}/language" />
</then>
</if>
<!-- TODO fix this - or just add as we go along -->
<mkdir dir="${extension.dest}/language" />
<mkdir dir="${extension.dest}/language/en-GB" />
<foreach list="${temp.languages}" param="lang" target="prep:copyLang" />
</then>
</if>
</target>
<target name="prep:copyLang">
<property name="lang.dest" value="${extension.dest}/${lang}" />
<!-- Find where the language source is (i.e. admin or site) -->
<if>
<available file="${lang}" type="file" />
<then>
<property name="lang.source" value="${lang}" />
</then>
<elseif>
<available file="administrator/${lang}" type="file" />
<then>
<property name="lang.source" value="administrator/${lang}" />
</then>
</elseif>
</if>
<!-- Delete any existing language files at the destination -->
<if>
<available file="${lang.dest}" type="file" />
<then>
<delete file="${lang.dest}" />
</then>
</if>
<!-- Do the language copy -->
<if>
<isset property="lang.source" />
<then>
<copy file="${lang.source}" tofile="${lang.dest}" overwrite="true" />
</then>
</if>
</target>
<target name="prep:createFolder">
<property name="folder.dest" value="${extension.dest}/${folder}" />
<if>
<available file="${folder.dest}" type="dir" />
<then>
<delete dir="${folder.dest}" />
</then>
</if>
<mkdir dir="${folder.dest}" />
</target>
<target name="prep:copyFiles">
<property name="file.dest" value="${extension.dest}/${filename}" />
<property name="file.source" value="${extension.path}/${filename}" />
<if>
<available file="${file.dest}" type="file" />
<then>
<delete file="${file.dest}" />
</then>
</if>
<copy file="${file.source}" tofile="${file.dest}" overwrite="true" />
</target>
<target name="prep:copyIndex">
<copy todir="${absname}">
<!-- Copy the index template file to the target folder -->
<fileset dir="${template.dir}">
<include name="index.html" />
</fileset>
</copy>
</target>
<target name="build:compress" description="Compresses each extension.">
<if>
<isset property="extension.name" />
<then>
<property name="path.tar" value="${package.dest}/packages/${extension.name}.tar.gz" />
<property name="path.zip" value="${package.dest}/packages/${extension.name}.zip" />
<property name="path.source" value="${extension.dest}" />
<!-- Build the TAR file -->
<if>
<available file="${path.tar}" type="file" />
<then>
<delete file="${path.tar}" />
</then>
</if>
<tar destfile="${path.tar}"
basedir="${path.source}"
includeEmptyDirs="0"
compression="gzip"
>
<fileset dir="${path.source}">
<include name="**" />
<exclude name=".*" />
</fileset>
</tar>
<!-- Build the ZIP file -->
<if>
<available file="${path.zip}" type="file" />
<then>
<delete file="${path.zip}" />
</then>
</if>
<zip destfile="${path.zip}" basedir="${path.source}">
<fileset dir="${path.source}">
<include name="**" />
<exclude name=".*" />
</fileset>
</zip>
</then>
</if>
</target>
<target name="prep:updateXml" description="Updates the XML manifest fields.">
<if>
<isset property="path.xml" />
<then>
<!-- TODO put in native PHP script to do this - use xmlstarlet for now -->
<exec command="xmlstarlet ed -P -L -u '/extension/version' --value '${package.version}' '${path.xml}'" checkreturn="false" />
<exec command="xmlstarlet ed -P -L -u '/extension/license' --value 'GNU General Public License version 2 or later; see LICENSE.txt' '${path.xml}'" checkreturn="false" />
<exec command="xmlstarlet ed -P -L -u '/extension/copyright' --value 'Copyright (C) 2013 Shaun Maunder. All rights reserved.' '${path.xml}'" checkreturn="false" />
<exec command="xmlstarlet ed -P -L -u '/extension/author' --value 'Shaun Maunder' '${path.xml}'" checkreturn="false" />
<exec command="xmlstarlet ed -P -L -u '/extension/authorEmail' --value '[email protected]' '${path.xml}'" checkreturn="false" />
<exec command="xmlstarlet ed -P -L -u '/extension/authorUrl' --value 'www.shmanic.com' '${path.xml}'" checkreturn="false" />
<exec command="xmlstarlet ed -P -L -u '/extension/buildDate' --value '${DATE}' '${path.xml}'" checkreturn="false" />
</then>
</if>
</target>
</project>