This repository has been archived by the owner on Nov 25, 2020. It is now read-only.
/
build-pydio.xml
720 lines (658 loc) · 30.3 KB
/
build-pydio.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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="phing-grammar.rng"
type="application/xml"
schematypens="http://relaxng.org/ns/structure/1.0" ?>
<project name="Pydio" default="build">
<import file="adhoctasks.xml"/>
<property file="build-pydio.properties"/>
<property name="env" value="testing"/>
<property name="skip_deploy" value="false"/>
<property name="build_linux" value="false"/>
<property name="build_channel" value="testing"/>
<property name="build.source_folder" value="${build.working_folder}/source"/>
<target name="build" description="Main sequence">
<if>
<equals arg1="${env}" arg2="release"/>
<then>
<phingcall target="prepare_upgrade"/>
<phingcall target="zip_upgrade"/>
<if>
<not><equals arg1="${skip_deploy}" arg2="true"/></not>
<then>
<phingcall target="deploy_upgrade"/>
</then>
</if>
</then>
<else>
<phingcall target="prepare_git"/>
</else>
</if>
<phingcall target="zip"/>
<if>
<not><equals arg1="${skip_deploy}" arg2="true"/></not>
<then>
<phingcall target="deploy"/>
<phingcall target="clean"/>
</then>
</if>
</target>
<target name="tag_version" description="Tag svn with the version, and upgrade version number for future builds to next_version">
<gittag
repository="${git.local_repository}"
name="${version}"
message="${version} tag"
/>
<reflexive>
<fileset dir=".">
<include pattern="build.properties" />
</fileset>
<filterchain>
<replaceregexp>
<regexp pattern="${version}" replace="${next_version}"/>
</replaceregexp>
</filterchain>
</reflexive>
<gitpush
repository="${git.local_repository}"
/>
</target>
<target name="usage" description="Describe this script usage">
<echo message="For releasing and deploying : phing -Denv=release -Dskip_deploy=false -Dbuild_channel=stable -Dbuild_linux=true -Dprevious_tag=XaZeR35 -Dprevious_version=4.0.4 -Dnew_version=4.2.0"/>
<echo message="For tagging : phing tag_version -Dversion=4.2.0 -Dnext_version=4.3.0"/>
</target>
<target name="deploy" description="Send package to FTP">
<phingcall target="ftp_deploy">
<property name="base_folder" value="${build.working_folder}/build"/>
<property name="remote_folder" value="${scp.dir}"/>
</phingcall>
<phingcall target="ftp_deploy">
<property name="base_folder" value="${build.working_folder}/build/plugins"/>
<property name="remote_folder" value="${scp.plugins_dir}"/>
</phingcall>
</target>
<target name="deploy_upgrade" description="Send package to FTP">
<phingcall target="ftp_deploy">
<property name="base_folder" value="${build.working_folder}/build/upgrade"/>
<property name="remote_folder" value="${scp.update_dir}"/>
</phingcall>
</target>
<!-- GIT VERSION -->
<target name="git_update" description="Clone or Pull depending on local repository presence.">
<if>
<available type="dir" file="${git.local_repository}"/>
<then>
<!-- GIT PULL -->
<gitpull
repository="${git.local_repository}"
all="true"
/>
</then>
<else>
<!-- GIT CLONE -->
<exec command="git clone ${git.remote_repository} ${git.local_repository}" passthru="true" />
<exec command="git checkout ${git.branch}" dir="${git.local_repository}" passthru="true"/>
</else>
</if>
</target>
<target name="prepare_git" description="Fetch Git Master, prepare VERSION and discriminate plugins">
<phingcall target="git_update"/>
<if>
<not><available type="dir" file="${build.source_folder}"/></not>
<then><mkdir dir="${build.source_folder}"/></then>
</if>
<tstamp>
<format property="VERSION_DATE" pattern="%Y-%m-%d"/>
</tstamp>
<!-- GET LAST COMMIT ID -->
<exec command="git rev-parse --short HEAD" dir="${git.local_repository}" outputProperty="LASTREVISION"/>
<if>
<equals arg1="${env}" arg2="testing"/>
<then>
<property name="package_name" value="pydio-${DSTAMP}-${LASTREVISION}"/>
</then>
<else>
<property name="package_name" value="pydio-core-${build.version}"/>
</else>
</if>
<property name="INNER_DIRECTORY" value="${build.source_folder}/${package_name}"/>
<if>
<available type="dir" file="${INNER_DIRECTORY}"/>
<then>
<delete dir="${INNER_DIRECTORY}"/>
</then>
</if>
<!-- EXPORT GIT CONTENT FROM core/src/ -->
<copy todir="${INNER_DIRECTORY}">
<fileset dir="${git.local_repository}/core/src" defaultexcludes="false">
<include name="*/**"/>
<exclude name=".gitignore"/>
</fileset>
</copy>
<!-- PREPARE VERSION FILE -->
<phingcall target="replace_variables">
<property name="passed_directory" value="${INNER_DIRECTORY}"/>
</phingcall>
<!-- RUN COMPOSER IF NECESSARY INSIDE CORE -->
<phingcall target="composer">
<property name="plugin_abs_dir" value="${INNER_DIRECTORY}/core"/>
</phingcall>
<!-- RUN COMPOSER IF NECESSARY INSIDE PLUGINS -->
<if>
<not><isset property="skip-plugins-composer"/></not>
<then>
<phingcall target="iterate-plugins">
<property name="plugins_dir" value="${INNER_DIRECTORY}/plugins"/>
<property name="target" value="composer"/>
</phingcall>
</then>
</if>
<!-- BUILD JAVASCRIPT -->
<if>
<not><isset property="skip-plugins-grunt"/></not>
<then>
<phingcall target="iterate-plugins">
<property name="plugins_dir" value="${INNER_DIRECTORY}/plugins"/>
<property name="target" value="grunt"/>
</phingcall>
</then>
</if>
<!-- DISCRIMINATE PLUGINS -->
<mkdir dir="${build.working_folder}/ext_plugins" />
<pydio-plugins-discriminate all="${INNER_DIRECTORY}/plugins" ext="${build.working_folder}/ext_plugins"/>
</target>
<target name="prepare_upgrade" description="Building upgrade package" depends="prepare_git">
<if>
<not><available type="dir" file="${build.working_folder}/upgrade"/></not>
<then><mkdir dir="${build.working_folder}/upgrade"/></then>
</if>
<property name="upgrade_export" value="${build.working_folder}/upgrade/export/pydio-core-upgrade-${previous_version}-${build.version}"/>
<mkdir dir="${upgrade_export}"/>
<mkdir dir="${upgrade_export}/UPGRADE"/>
<pydio-git-summarize
commit1="${previous_tag}"
commit2="${LASTREVISION}"
summarizeFile="${build.working_folder}/upgrade/git_summarize_core"
repository="${git.local_repository}"
/>
<pydio-parse-git-summarize
summarizeFile="${build.working_folder}/upgrade/git_summarize_core"
sourceDir="${git.local_repository}"
prefixPath="core/src"
upgradeDir="${upgrade_export}"
extPluginsFolder="${build.working_folder}/ext_plugins"
/>
<phingcall target="replace_variables">
<property name="passed_directory" value="${upgrade_export}"/>
</phingcall>
<!-- RE-RUN CORE COMPOSER IF NECESSARY (Any changes appeared in core/src) -->
<if>
<or>
<!-- There was a change in core/src, rerun to make sure autoloader is up-to-date -->
<available type="dir" file="${upgrade_export}/core/src"/>
<!-- There was a change in composer.json, rerun to make sure vendor/ is up-to-date -->
<available type="file" file="${upgrade_export}/core/composer.json"/>
</or>
<then>
<copy file="${git.local_repository}/core/src/core/composer.json" todir="${upgrade_export}/core" overwrite="true"/>
<phingcall target="composer">
<property name="plugin_abs_dir" value="${upgrade_export}/core"/>
</phingcall>
</then>
</if>
<!-- RE-RUN COMPOSER & GRUNT IF NECESSARY ON PLUGINS -->
<phingcall target="iterate-plugins">
<property name="plugins_dir" value="${git.local_repository}/core/src/plugins"/>
<property name="upgrade_export" value="${upgrade_export}"/>
<property name="local_repository_root" value="${git.local_repository}/core/src"/>
<property name="target" value="force-update-if-package-json"/>
</phingcall>
<!-- COPY RELEASE NOTE -->
<copy file="${upgrade_export}/conf/RELEASE_NOTE" toFile="${upgrade_export}/UPGRADE/NOTE"/>
<copy file="${git.local_repository}/core/src/conf/VERSION" toFile="${upgrade_export}/conf/VERSION">
<filterchain>
<replacetokens begintoken="##" endtoken="##">
<token key="VERSION_NUMBER" value="${build.version}"/>
<token key="DB_VERSION" value="${build.dbversion}"/>
<token key="VERSION_DATE" value="${VERSION_DATE}"/>
<token key="REVISION" value="${LASTREVISION}"/>
</replacetokens>
</filterchain>
</copy>
<copy file="${git.local_repository}/core/src/conf/VERSION.php" toFile="${upgrade_export}/conf/VERSION.php">
<filterchain>
<replacetokens begintoken="##" endtoken="##">
<token key="VERSION_NUMBER" value="${build.version}"/>
<token key="DB_VERSION" value="${build.dbversion}"/>
<token key="VERSION_DATE" value="${VERSION_DATE}"/>
<token key="REVISION" value="${LASTREVISION}"/>
</replacetokens>
</filterchain>
</copy>
<!-- ADDITIONAL UPGRADE SCRIPT -->
<phingcall target="add_update_script">
<property name="extension" value="php"/>
<property name="target_name" value="PHP-SCRIPT"/>
</phingcall>
<phingcall target="add_update_script">
<property name="extension" value="html"/>
<property name="target_name" value="NOTE-HTML"/>
</phingcall>
<phingcall target="add_update_script">
<property name="extension" value="sql"/>
<property name="target_name" value="DB-UPGRADE.sql"/>
</phingcall>
<phingcall target="add_update_script">
<property name="extension" value="mysql"/>
<property name="target_name" value="DB-UPGRADE.mysql"/>
</phingcall>
<phingcall target="add_update_script">
<property name="extension" value="pgsql"/>
<property name="target_name" value="DB-UPGRADE.pgsql"/>
</phingcall>
<phingcall target="add_update_script">
<property name="extension" value="sqlite"/>
<property name="target_name" value="DB-UPGRADE.sqlite"/>
</phingcall>
<phingcall target="add_update_triggers">
<property name="input_folder" value="${git.local_repository}/dist/php"/>
<property name="output_folder" value="${upgrade_export}/UPGRADE"/>
<property name="version" value="${build.version}"/>
</phingcall>
</target>
<target name="zip" description="Package as Zip archive">
<mkdir dir="${build.working_folder}/build" />
<mkdir dir="${build.working_folder}/build/plugins" />
<tstamp/>
<exec command="git rev-parse --short HEAD" dir="${git.local_repository}" outputProperty="LASTREVISION"/>
<if>
<equals arg1="${env}" arg2="testing"/>
<then>
<property name="package_name" value="pydio-${DSTAMP}-${LASTREVISION}"/>
</then>
<else>
<property name="package_name" value="pydio-core-${build.version}"/>
</else>
</if>
<property name="packaged_zip" value="${package_name}.zip"/>
<property name="packaged_tar" value="${package_name}.tar.gz"/>
<zip
destfile="${build.working_folder}/build/${packaged_zip}"
includeemptydirs="true"
><fileset dir="${build.source_folder}" defaultexcludes="false"><include name="*/**"/></fileset></zip>
<tar
destfile="${build.working_folder}/build/${packaged_tar}"
includeemptydirs="true"
compression="gzip"
><fileset dir="${build.source_folder}" defaultexcludes="false"><include name="*/**"/></fileset></tar>
<if>
<equals arg1="${env}" arg2="testing"/>
<then>
<copy todir="${build.working_folder}/build/pydio-latest">
<fileset dir="${build.source_folder}/${package_name}/" defaultexcludes="false"><include name="*/**"></include></fileset>
</copy>
<zip
destfile="${build.working_folder}/build/pydio-latest.zip"
includeemptydirs="true"
><fileset dir="${build.working_folder}/build/" defaultexcludes="false"><include name="pydio-latest/**"/></fileset></zip>
<tar
destfile="${build.working_folder}/build/pydio-latest.tar.gz"
includeemptydirs="true"
compression="gzip"
><fileset dir="${build.working_folder}/build/" defaultexcludes="false"><include name="pydio-latest/**"/></fileset></tar>
<delete dir="${build.working_folder}/build/pydio-latest" quiet="true"/>
</then>
</if>
<phingcall target="build_external_plugins"/>
<if>
<equals arg1="${build_linux}" arg2="true"/>
<then>
<phingcall target="linux_packages">
<property name="packaged_zip" value="${build.working_folder}/build/${packaged_zip}"/>
</phingcall>
</then>
</if>
</target>
<target name="zip_upgrade" description="Packaging upgrade">
<mkdir dir="${build.working_folder}/build" />
<mkdir dir="${build.working_folder}/build/upgrade" />
<property name="packaged_zip" value="pydio-core-upgrade-${previous_version}-${build.version}.zip"/>
<zip
destfile="${build.working_folder}/build/upgrade/${packaged_zip}"
includeemptydirs="true"
><fileset dir="${build.working_folder}/upgrade/export/" defaultexcludes="false"><include name="*/**"/></fileset></zip>
</target>
<target name="add_update_script" description="Additional upgrade scripts, requires extension and target_name properties">
<if>
<available type="file" file="${git.local_repository}/dist/php/${build.version}.${extension}"/>
<then>
<copy file="${git.local_repository}/dist/php/${build.version}.${extension}" toFile="${upgrade_export}/UPGRADE/${target_name}"/>
</then>
</if>
</target>
<target name="add_update_triggers" description="Look for pre/post triggers and append them to the package">
<copy todir="${output_folder}" verbose="true">
<fileset dir="${input_folder}">
<include name="${version}-*-*.php"/>
</fileset>
<mapper type="regexp" from="^(.*)-(.*)-(.*).php" to="PHP--\3-\2.php"/>
</copy>
</target>
<target name="build_external_plugins">
<foreach param="filename" absparam="absfilename" target="zip_plugin">
<fileset dir="${build.working_folder}/ext_plugins">
<include name="*.*"/>
</fileset>
</foreach>
</target>
<target name="zip_plugin" >
<tstamp/>
<property name="packaged_plugin" value="plugin-${filename}-${DSTAMP}.zip"/>
<property name="packaged_plugin_tar" value="plugin-${filename}-${DSTAMP}.tar.gz"/>
<zip
destfile="${build.working_folder}/build/plugins/${packaged_plugin}"
includeemptydirs="true"
><fileset dir="${absfilename}" defaultexcludes="false"><include name="*/**"/></fileset></zip>
<tar
basedir="${absfilename}"
destfile="${build.working_folder}/build/plugins/${packaged_plugin_tar}"
includeemptydirs="true"
compression="gzip"
><fileset dir="${absfilename}" defaultexcludes="false"><include name="*/**"/></fileset></tar>
</target>
<target name="linux_packages" description="Trigger RPM and Debian packages builds, release ZIP only.">
<mkdir dir="${build.working_folder}/dist"/>
<mkdir dir="${build.working_folder}/rpm"/>
<mkdir dir="${build.working_folder}/deb"/>
<mkdir dir="${build.working_folder}/deb/builddeb"/>
<!-- Extract Last Revision -->
<copy todir="${build.working_folder}/dist">
<fileset dir="${git.local_repository}/dist" defaultexcludes="false">
<include name="**/*"/>
<exclude name=".gitignore"/>
</fileset>
</copy>
<exec command="git rev-parse --short HEAD" dir="${git.local_repository}" outputProperty="LASTREVISION"/>
<if>
<equals arg1="${build_channel}" arg2="stable"/>
<then>
<property name="debian_distribution" value="stable"/>
<property name="rpm_distribution" value="pydio-stable"/>
</then>
<else>
<property name="debian_distribution" value="testing"/>
<property name="rpm_distribution" value="pydio-testing"/>
</else>
</if>
<echo message="DEBIAN DISTRIB IS ${debian_distribution} and RPM is ${rpm_distribution}"/>
<!-- TOKEN REPLACE THE RPM SPEC FILE -->
<copy file="${build.working_folder}/dist/rpm/pydio.spec.tpl" overwrite="true" toFile="${build.working_folder}/rpm/pydio.spec">
<filterchain>
<replacetokens begintoken="##" endtoken="##">
<token key="VERSION_NUMBER" value="${build.version}"/>
<token key="CHANNEL" value="${build_channel}"/>
</replacetokens>
</filterchain>
</copy>
<copy file="${packaged_zip}" toDir="${rpm.build_folder}/SOURCES" overwrite="true"/>
<copy file="${build.working_folder}/dist/rpm/pydio.conf" toDir="${rpm.build_folder}/SOURCES" overwrite="true"/>
<exec command="rpmbuild --sign -ba ${build.working_folder}/rpm/pydio.spec"
passthru="true"/>
<copy overwrite="true"
file="${rpm.build_folder}/RPMS/noarch/pydio-${build.version}-1.noarch.rpm"
toDir="${build.working_folder}/build"/>
<copy overwrite="true"
file="${rpm.build_folder}/SRPMS/pydio-${build.version}-1.src.rpm"
toDir="${build.working_folder}/build"/>
<!-- PREPARE DEBIAN BUILD -->
<copy toDir="${build.working_folder}/deb/builddeb" overwrite="true">
<fileset dir="${build.working_folder}/dist/deb-pydio">
<include name="**/*"/>
</fileset>
<fileset dir="${build.source_folder}/" defaultexcludes="false">
<include name="**/*"/>
</fileset>
</copy>
<!-- UPGRADE Makefile -->
<reflexive>
<fileset dir="${build.working_folder}/deb/builddeb">
<include pattern="Makefile"/>
</fileset>
<filterchain>
<replacetokens begintoken="##" endtoken="##">
<token key="KEY_ID" value="${build.signing_key_id}"/>
<token key="DIST" value="${debian_distribution}"/>
</replacetokens>
</filterchain>
</reflexive>
<!-- UPGRADE CHANGELOG -->
<tstamp><format property="FORMATTED_DATE" pattern="%a, %d %b %Y %H:%M:%S %z"/></tstamp>
<reflexive>
<fileset dir="${build.working_folder}/deb/builddeb/debian">
<include pattern="changelog.tpl"/>
</fileset>
<filterchain>
<replacetokens begintoken="##" endtoken="##">
<token key="VERSION_NUMBER" value="${build.version}"/>
<token key="FORMATTED_DATE" value="${FORMATTED_DATE}"/>
<token key="DIST" value="${debian_distribution}"/>
</replacetokens>
</filterchain>
</reflexive>
<loadfile property="previous_changelog" file="${build.working_folder}/deb/builddeb/debian/changelog"/>
<append destFile="${build.working_folder}/deb/builddeb/debian/changelog.tpl" text="${previous_changelog}"/>
<move file="${build.working_folder}/deb/builddeb/debian/changelog.tpl" tofile="${build.working_folder}/deb/builddeb/debian/changelog" overwrite="true"/>
<exec command="make builddeb" dir="${build.working_folder}/deb/builddeb" passthru="true"/>
<copy toDir="${build.working_folder}/build">
<fileset dir="${build.working_folder}/deb">
<include name="pydio_*.deb"/>
</fileset>
</copy>
<!-- TODO: SHOULD REPORT BACK THE CHANGELOG AND COMMIT -->
<!-- UPDATE APT REPOSITORY -->
<exec command="reprepro --ask-passphrase -Vb . include ${debian_distribution} ${build.working_folder}/deb/pydio_${build.version}_amd64.changes" dir="${build.repositories_folder}/apt/" passthru="true"/>
<!-- UPDATE EL6 RPM REPOSITORY -->
<copy file="${build.working_folder}/build/pydio-${build.version}-1.noarch.rpm" toDir="${build.repositories_folder}/el6/${rpm_distribution}/"/>
<exec command="createrepo ." dir="${build.repositories_folder}/el6/${rpm_distribution}/" passthru="true"/>
<!-- UPDATE EL6 SOURCES REPOSITORY -->
<copy file="${build.working_folder}/build/pydio-${build.version}-1.src.rpm" toDir="${build.repositories_folder}/el6/pydio-sources/"/>
<exec command="createrepo ." dir="${build.repositories_folder}/el6/pydio-sources/" passthru="true"/>
<!-- NOW DEPLOY, TO REMOTE COPY -->
<if>
<not><equals arg1="${skip_deploy}" arg2="true"/></not>
<then>
<!-- SYNCHRONIZE -->
<scp
username="${repository_machine.user}"
password="${repository_machine.password}"
host="${repository_machine.host}"
todir="${repository_machine.folder}">
<fileset dir="${build.repositories_folder}">
<include name="**/*" />
</fileset>
</scp>
</then>
</if>
</target>
<target name="iterate-plugins">
<foreach param="plugin" absparam="plugin_abs_dir" target="${target}">
<fileset dir="${plugins_dir}">
<include name="*"/>
</fileset>
</foreach>
</target>
<!-- We should have a ${local_repository_root} and ${upgrade_export} from upper scope -->
<target name="force-update-if-package-json">
<!-- Looking for package.json File -->
<if>
<available file="${plugin_abs_dir}/package.json"/>
<then>
<pydio-read-package-json file="${plugin_abs_dir}/package.json"/>
<if>
<not><equals arg1="${js_source_path}" arg2="__NOT_FOUND__"/></not>
<then>
<if>
<available type="dir" file="${upgrade_export}/plugins/${plugin}/${js_source_path}"/>
<then>
<copy todir="${upgrade_export}/plugins/${plugin}/${js_source_path}">
<fileset dir="${local_repository_root}/plugins/${plugin}/${js_source_path}" defaultexcludes="false">
<include name="*/**"/>
</fileset>
</copy>
</then>
</if>
</then>
</if>
<if>
<not><equals arg1="${css_source_path}" arg2="__NOT_FOUND__"/></not>
<then>
<if>
<available type="dir" file="${upgrade_export}/plugins/${plugin}/${css_source_path}"/>
<then>
<copy todir="${upgrade_export}/plugins/${plugin}/${css_source_path}">
<fileset dir="${local_repository_root}/plugins/${plugin}/${css_source_path}" defaultexcludes="false">
<include name="*/**"/>
</fileset>
</copy>
</then>
</if>
</then>
</if>
<echo message="REBUILD JS FOR PLUGIN ${plugin}"/>
<copy todir="${upgrade_export}/plugins/${plugin}">
<fileset dir="${local_repository_root}/plugins/${plugin}">
<include name="Gruntfile.js"/>
<include name="package.json"/>
</fileset>
</copy>
<phingcall target="grunt">
<property name="plugin_abs_dir" override="true" value="${upgrade_export}/plugins/${plugin}"/>
</phingcall>
</then>
</if>
<!-- Looking for Composer.json File -->
<if>
<and>
<available file="${plugin_abs_dir}/composer.json"/>
<available type="dir" file="${upgrade_export}/plugins/${plugin}/src"/>
</and>
<then>
<copy todir="${upgrade_export}/plugins/${plugin}/src">
<fileset dir="${local_repository_root}/plugins/${plugin}/src" defaultexcludes="false">
<include name="*/**"/>
</fileset>
</copy>
<echo message="RERUN COMPOSER JS FOR PLUGIN ${plugin}"/>
<copy todir="${upgrade_export}/plugins/${plugin}">
<fileset dir="${local_repository_root}/plugins/${plugin}">
<include name="composer.json"/>
</fileset>
</copy>
<phingcall target="composer">
<property name="plugin_abs_dir" override="true" value="${upgrade_export}/plugins/${plugin}"/>
</phingcall>
</then>
</if>
</target>
<target name="grunt">
<if>
<available file="${plugin_abs_dir}/package.json"/>
<then>
<!-- BUILD JAVASCRIPT -->
<exec command="npm install" dir="${plugin_abs_dir}" passthru="true"/>
<exec command="grunt" dir="${plugin_abs_dir}" passthru="true"/>
<delete dir="${plugin_abs_dir}/node_modules"/>
</then>
</if>
</target>
<target name="composer">
<if>
<available type="file" file="${plugin_abs_dir}/composer.json"/>
<then>
<exec command="composer install --optimize-autoloader"
dir="${plugin_abs_dir}"
passthru="true"
/>
</then>
</if>
</target>
<target name="clean" description="Clean all working folders">
<foreach list="${build.source_folder},${git.local_repository},${build.working_folder}/build,${build.working_folder}/ext_plugins,${build.working_folder}/upgrade,${build.working_folder}/dist,${build.working_folder}/deb,${build.working_folder}/rpm" param="filename" absparam="absfilename" target="delete_me">
</foreach>
</target>
<target name="delete_me">
<if>
<available file="${filename}"/>
<then>
<delete dir="${filename}"/>
</then>
<elseif>
<available file="${absfilename}"/>
<then>
<delete file="${absfilename}"/>
</then>
</elseif>
</if>
</target>
<!-- GENERIC TASKS -->
<target name="replace_variables" description="Replace version, revision number, etc in files">
<reflexive>
<fileset dir="${passed_directory}">
<include pattern="conf/VERSION.php"/>
<include pattern="conf/VERSION"/>
<include pattern="conf/RELEASE_NOTE"/>
</fileset>
<filterchain>
<replacetokens begintoken="##" endtoken="##">
<token key="VERSION_NUMBER" value="${build.version}"/>
<token key="DB_VERSION" value="${build.dbversion}"/>
<token key="VERSION_DATE" value="${VERSION_DATE}"/>
<token key="REVISION" value="${LASTREVISION}"/>
</replacetokens>
</filterchain>
</reflexive>
</target>
<target name="ftp_deploy" description="Generic FTP deployment">
<if>
<equals arg1="${scp.password}" arg2="__LOCAL_KEY__"/>
<then>
<echo message="Sending ${base_folder} zips to ${scp.host}:${remote_folder}"/>
<exec command="scp -P ${scp.port} *.zip *.tar.gz ${scp.username}@${scp.host}:${remote_folder}" dir="${base_folder}" passthru="true"/>
</then>
<else>
<scp
username="${scp.username}"
password="${scp.password}"
host="${scp.host}"
port="${scp.port}"
todir="${remote_folder}">
<fileset dir="${base_folder}">
<include name="*.zip" />
<include name="*.tar.gz"/>
</fileset>
</scp>
</else>
</if>
<!--
<ftpdeploy
host="${ftp.host}"
port="${ftp.port}"
username="${ftp.username}"
password="${ftp.password}"
passive="${ftp.passive}"
dir="${remote_folder}">
<fileset dir="${base_folder}">
<include name="*.zip"/>
<include name="*.tar.gz"/>
</fileset>
</ftpdeploy>
-->
<echo message="Successfully sent zip and tars from ${base_folder} to ${scp.host}/${remote_folder}"/>
</target>
<target name="lint" description="Check syntax of sources">
<phplint>
<fileset dir="${build.source_folder}">
<include name="**/*.php"/>
</fileset>
</phplint>
</target>
</project>