-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.xml
1236 lines (1194 loc) · 63.4 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
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
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="UTF-8"?>
<project name="opensource-setup" default="help" basedir=".">
<dirname property="root-dir" file="."/>
<property file="build.local.properties"/>
<property file="${root-dir}/build.local.properties"/>
<property file="pom.properties" />
<property file="build.server.properties" />
<condition property="osname" value="macosx">
<os name="Mac OS X" />
</condition>
<condition property="osname" value="windows">
<os name="Windows XP" />
</condition>
<property file="build.${osname}.properties" />
<condition property="osfamily" value="winnt">
<os family="winnt" />
</condition>
<condition property="osfamily" value="unix">
<os family="unix" />
</condition>
<property file="build.${osfamily}.properties" />
<property file="build.properties" />
<!-- set environment variables -->
<property name="env.ANT_HOME" value="${ant-home}" />
<property name="env.MAVEN_HOME" value="${maven-home}" />
<property name="env.MAVEN_MEMORY_OPTS" value="${maven-memory-opts}" />
<property name="env.MAVEN_OPTS" value="${maven-memory-opts}" />
<property name="env.JAMES_HOME" value="${james-home}" />
<property name="env.GEM_HOME" value="${tools-dir}${file.separator}ruby${file.separator}gems" />
<property environment="env" />
<tstamp>
<format property="time-suffix" pattern="yyyy-MM-dd-HH-mm-ss" />
</tstamp>
<property name="html-project-list" value="jericho-html"/>
<!--
<property name="t4-project-list" value="amplafi-hivemind,amplafi-tapestry4-test,amplafi-tapestry4-utils,amplafi-tapestry4-springsecurity"/>
<property name="flow-project-list" value="amplafi-flow-core,amplafi-flow-client,amplafi-flow-tapestry4,amplafi-flow-tutorial" />
-->
<property name="t4-project-list" value="amplafi-hivemind"/>
<property name="flow-project-list" value="amplafi-flow-core,amplafi-flow-client" />
<property name="opensource-project-list" value="amplafi-opensource-parent,amplafi-json,amplafi-sworddance,${flow-project-list},${t4-project-list},${html-project-list},liquibase-hibernate,logglylog4j"/>
<!-- TARGETS -->
<!-- needed because ant-contrib may not yet be copied to the ant/lib directory -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${tools-dir}/ant-contrib-${ant-contrib-build}/ant-contrib-${ant-contrib-build}.jar" onerror="fail"/>
<target name="help" description="HOW TO GET STARTED">
<echo>Getting started:</echo>
<echo>You are running on : ${osname} ${osfamily} / ${os.version} ${os.name} ${os.arch}</echo>
<echo>Standard tools needed: ( you may have some of them already )
1. eclipse 3.5 or higher from ${remote-eclipse-site}
2. java ${java-build} (Current: runtime: ${java.runtime.version} compiler: ${java.version} )
Run: "opensource-one-time-setup" will check and download any missing tools. You may need to run this repeatedly.
Run: "apache-ant-1.9.0${file.separator}bin${file.separator}ant -p" for other commands
</echo>
</target>
<target name="opensource-one-time-setup" depends="_configure_environment,update-source,validate-tools-opensource,dependencies-all-opensource,complete-one-time-config-opensource,_build-clean-all-opensource"
description="configures the opensource tools">
</target>
<target name="complete-one-time-config-opensource" depends="dependencies-all-opensource,_build-clean-all-opensource">
</target>
<!-- support tasks-->
<target name="_configure_environment">
<!-- check if ANT_HOME is set-->
<antcall target="_check-environment-variable">
<param name="environment-variable" value="ANT_HOME" />
</antcall>
<!-- check if MAVEN_HOME is set-->
<antcall target="_check-environment-variable">
<param name="environment-variable" value="MAVEN_HOME" />
</antcall>
<!-- check if JAMES_HOME is set-->
<antcall target="_check-environment-variable">
<param name="environment-variable" value="JAMES_HOME" />
</antcall>
</target>
<!-- This target assumes the environment variables are already loaded in env -->
<target name="_check-environment-variable">
<fail unless="environment-variable" />
<property environment="test-env" />
<property name="nested-system-environment-variable" value="test-env.${environment-variable}" />
<_propertycopy name="system-environment-variable" from="${nested-system-environment-variable}" />
<property name="nested-using-environment-variable" value="env.${environment-variable}" />
<_propertycopy name="using-environment-variable" from="${nested-using-environment-variable}" />
<condition property="set-warning">
<and>
<isset property="test-env.${environment-variable}" />
<not>
<equals arg1="${using-environment-variable}" arg2="${system-environment-variable}" />
</not>
</and>
</condition>
<antcall target="_environment-variable-warning">
<param name="warning-system-variable" value="${environment-variable}" />
<param name="warning-old-variable" value="${system-environment-variable}" />
<param name="warning-using-variable" value="${using-environment-variable}" />
</antcall>
</target>
<target name="_environment-variable-warning" if="set-warning">
<fail unless="warning-system-variable" />
<fail unless="warning-old-variable" />
<fail unless="warning-using-variable" />
<echo>WARNING: Environment variable ${warning-system-variable} is set to: ${warning-old-variable}
and instead using: ${warning-using-variable}
</echo>
</target>
<!-- hack obtained from http://ant.apache.org/faq.html#propertyvalue-as-name-for-property -->
<!-- hack allows to use nested properties -->
<macrodef name="_propertycopy">
<attribute name="name" />
<attribute name="from" />
<sequential>
<property name="@{name}" value="${@{from}}" />
</sequential>
</macrodef>
<!-- ============================================================================= -->
<!-- eclipse configuration -->
<!-- ============================================================================= -->
<target name="eclipse-one-time-config-opensource" depends="_eclipse-init-opensource,eclipse-setup-all-opensource" description="You will only need to run this ONCE if Eclipse complains about M2_REPO is not set.">
<echo>TODO: verify that YOU are running latest eclipse!!!!!!</echo>
<!-- need to add "-Dfile.encoding=UTF-8" (no quotes) to eclipse.ini see: http://maven.apache.org/general.html#special-characters-site -->
</target>
<target name="_eclipse-init-opensource" depends="_eclipse-init-maven-var" />
<target name="eclipse-setup" depends="dependencies" description="Recreate the eclipse project files">
<echo>Copy the 'standard' eclipse configuration to where eclipse expects it</echo>
<echo>Ideally q4e would solve this problem :-P</echo>
<antcall target="_mvn-no-tests">
<param name="mvn-target" value="eclipse:clean" />
</antcall>
<antcall target="_mvn-no-tests">
<!-- TODO: -DdownloadJavadocs=true -DdownloadSources=true -->
<param name="mvn-target" value="eclipse:eclipse" />
</antcall>
<!-- default settings should not copy over the previously existing files
<copy todir=".settings" failonerror="false" verbose="true">
<fileset dir="eclipse.${osname}.settings"/>
</copy>
<copy todir=".settings" failonerror="false" verbose="true">
<fileset dir="eclipse.default.settings"/>
</copy>
-->
</target>
<target name="eclipse-setup-all-opensource" description="Setup eclipse for the opensource projects">
<antcall target="_opensource-list-calls">
<param name="target-call" value="_eclipse-setup-one-project" />
<param name="target-parameter" value="project-name" />
</antcall>
</target>
<target name="_eclipse-setup-one-project">
<fail unless="project-name" />
<antcall target="eclipse-setup">
<param name="mvn-profile" value="-f ${root-dir}${file.separator}${project-name}${file.separator}pom.xml" />
</antcall>
</target>
<target name="_eclipse-init-maven-var">
<echo>Creating Eclipse variable (M2_REPO) to point to the maven repository.</echo>
<antcall target="_mvn-no-tests">
<param name="mvn-profile" value="-Declipse.workspace=${root-dir}" />
<param name="mvn-target" value="eclipse:configure-workspace" />
</antcall>
</target>
<target name="build-clean-opensource" depends="clean-opensource,build-opensource" description="clean,build">
</target>
<target name="build-opensource" description="Installs all of the opensource projects in the maven repository. Does not run the tests.">
<antcall target="_opensource-list-calls">
<param name="target-call" value="_build-clean-for-one-project-using-maven" />
<param name="target-parameter" value="project-name" />
<param name="mvn-target" value="install" />
</antcall>
</target>
<target name="clean-opensource" description="Cleans the all of the opensource projects">
<echo>Cleaning project...</echo>
<antcall target="_opensource-list-calls">
<param name="target-call" value="_build-clean-for-one-project-using-maven" />
<param name="target-parameter" value="project-name" />
<param name="mvn-target" value="clean" />
</antcall>
</target>
<target name="_build-clean-all-opensource">
<antcall target="_opensource-list-calls">
<param name="target-call" value="_build-clean-for-one-project-using-maven" />
<param name="target-parameter" value="project-name" />
<param name="mvn-target" value="clean install" />
</antcall>
</target>
<target name="_build-clean-for-one-project-using-maven">
<!-- TODO: Find a way to have maven calculate the dependencies of multiple projects and perform the clean install as a single build.
Calling clean install on maven projects one at a time is slow,
because maven will clean build all of the dependencies as well.
There has to be a way to call maven once with all of the needed project information-->
<fail unless="project-name" />
<fail unless="mvn-target" message="Need to specify the target(s) (ex. clean)" />
<antcall target="_mvn-no-tests">
<param name="mvn-profile" value="-f ${root-dir}${file.separator}${project-name}${file.separator}pom.xml" />
</antcall>
</target>
<!-- ============================================================================= -->
<!-- getting source code and libraries -->
<!-- ============================================================================= -->
<target name="dependencies-all-opensource" description="calls all opensource targets separately with the dependency:sources target for mvn">
<!-- Get dependencies for each project separately-->
<antcall target="_opensource-list-calls">
<param name="target-call" value="_get-dependencies-for-one-project" />
<param name="target-parameter" value="project-name" />
</antcall>
</target>
<target name="_get-dependencies-for-one-project">
<fail unless="project-name" />
<antcall target="dependencies">
<param name="mvn-profile" value="-f ${root-dir}${file.separator}${project-name}${file.separator}pom.xml" />
</antcall>
</target>
<!-- ============================================================================ -->
<!-- List of opensource projects -->
<!-- Target _opensource-list-calls is like a list that antcalls the ${target-call} and supplies the call with it's item on the list.-->
<!-- General usage of the task is as follows:
<antcall target="_opensource-list-calls">
<param name="target-call" value="this is where you put the target to call for each item" />
<param name="target-parameter" value="if the target needs the opensource project name in a certain parameter put the string literal of that parameter in this parameter" />
<param name="other target parameters" value="any other parameters that you want to set for the target can be passed on multile lines starting with this one. These parameters will not be used by _opensource-list-calls but are passed on to the target that it calls." />
</antcall> -->
<!-- ============================================================================ -->
<target name="_opensource-list-calls">
<fail unless="target-call" />
<fail unless="target-parameter" />
<!-- amplafi-tools-->
<!-- The amplafi-tools project is not on the list because I don't know how ant will react when changing the build.xml file at the same time it is running. Like when performing a update-source -->
<property name="project-owner" value="amplafi"/>
<for list="${opensource-project-list}" param="project">
<sequential>
<echo>Calling ${target-call} for @{project}</echo>
<antcall target="${target-call}">
<param name="${target-parameter}" value="@{project}" />
</antcall>
</sequential>
</for>
</target>
<target name="dependencies" description="Get the dependent libraries -Dmvn-profile needs to be set">
<echo>
=============================================
If this may take a looooooooooooong time if you have a slow connection
Go eat dinner, watch a movie, etc -- but check back just in case something breaks
(Or it finishes really quickly!)
=============================================
</echo>
<antcall target="_mvn-no-tests">
<param name="mvn-target" value="dependency:sources" />
</antcall>
</target>
<!-- git tasks-->
<!-- missing something on how to do push from eclipse -->
<target name="git-push-all" description="git commit and push all - This target needs a -Dm="reason for changes here"">
<!-- commit/push all from list. -->
<antcall target="git-push">
<param name="project" value="amplafi-tools"/>
</antcall>
<antcall target="_opensource-list-calls">
<param name="target-call" value="git-push" />
<param name="target-parameter" value="project" />
</antcall>
</target>
<target name="git-push" description="git commit/push -Dproject needs to be set">
<fail unless="project" />
<echo>${project}</echo>
<property name="local-directory" value="${gitrootdir}/${project}" />
<exec executable="${git-exec}" dir="${local-directory}">
<arg value="diff" />
</exec>
<fail unless="commit-message" />
<exec executable="${git-exec}" dir="${local-directory}">
<arg value="commit" />
<arg value="-a" />
<arg value="-q" />
<arg value="-m" />
<arg value="${commit-message}" />
</exec>
<exec executable="${git-exec}" dir="${local-directory}">
<arg value="push" />
</exec>
</target>
<target name="git-add-commit" description="git add/commit -Dm, -Ddirectory needs to be set">
<exec dir="${directory}" executable="${git-exec}" failonerror="true">
<arg value="add"/>
<arg value="-A"/>
<arg value="."/>
</exec>
<exec dir="${directory}" executable="${git-exec}" failonerror="false">
<arg value="commit"/>
<arg value="-m"/>
<arg value="${commit-message}"/>
</exec>
</target>
<target name="git-diff-all" description="git diff all">
<antcall target="_opensource-list-calls">
<param name="target-call" value="git-diff" />
<param name="target-parameter" value="project" />
</antcall>
</target>
<target name="git-diff" description="git diff -Dproject needs to be set">
<fail unless="project" />
<property name="local-directory" value="${gitrootdir}/${project}" />
<echo>${project}</echo>
<exec executable="${git-exec}" dir="${local-directory}">
<arg value="diff" />
</exec>
</target>
<!-- TODO: check to make sure git clone on existing directory o.k. prob should switch to _git-update if directory already exists -->
<target name="git-pull" description="git pull/clone. Parameters project-owner, project, branch">
<fail unless="project" />
<property name="gitrootdir" value="${root-dir}"/>
<!-- supply default local directory name as the project name -->
<property name="local-directory" value="${gitrootdir}/${project}" />
<echo>Local dir: ${local-directory}</echo>
<condition property="_dont-git-pull">
<not>
<available file="${local-directory}/.git" />
</not>
</condition>
<antcall target="_git-pull"/>
<condition property="_dont-git-clone">
<available file="${local-directory}/.git" />
</condition>
<antcall target="_git-clone"/>
</target>
<target name="_git-clone" unless="_dont-git-clone" depends="_gitconfig-warning,_ssh-warning">
<fail unless="project" message="Need 'project' to be set."/>
<fail message="project-owner or git-url needs to be set">
<condition>
<not>
<or>
<isset property="project-owner"/>
<isset property="git-url"/>
</or>
</not>
</condition>
</fail>
<property name="fail-if-fail" value="true"/>
<property name="local-directory" value="${gitrootdir}/${project}" />
<basename file="${local-directory}" property="__local-directory-root"/>
<mkdir dir="${__local-directory-root}" />
<property name="git-url" value="${github-base}/${project-owner}/${project}.git" />
<property name="branch" value="master"/>
<echo>Cloning ${git-url} (branch : ${branch} ) into ${local-directory} (git-exec: ${git-exec} )</echo>
<exec executable="${git-exec}" dir="${gitrootdir}" resultproperty="_git-error-code" failonerror="${fail-if-fail}" failifexecutionfails="${fail-if-fail}">
<arg value="clone" />
<arg value="--branch"/>
<arg value="${branch}"/>
<arg value="${git-url}" />
<arg value="${local-directory}"/>
</exec>
</target>
<target name="_git-pull" unless="_dont-git-pull">
<fail unless="project" />
<property name="fail-if-fail" value="true"/>
<echo>git pulling ${local-directory}</echo>
<exec executable="${git-exec}" dir="${local-directory}" resultproperty="_git-error-code" failonerror="${fail-if-fail}" failifexecutionfails="${fail-if-fail}">
<arg value="pull" />
</exec>
</target>
<target name="_gitconfig-exists-check">
<condition property="_gitconfig-exist">
<available file="${user.home}${file.separator}.gitconfig" />
</condition>
</target>
<target name="_sshconfig-exists-check">
<condition property="_sshconfig-exists">
<available file="${user.home}${file.separator}.ssh"/>
</condition>
</target>
<target name="_ssh-warning" depends="_sshconfig-exists-check">
<fail unless="_sshconfig-exists">
No ${user.home}${file.separator}.ssh directory
You need to setup ssh configuration correctly with github
See https://help.github.com/articles/generating-ssh-keys
</fail>
</target>
<target name="_gitconfig-warning" depends="_gitconfig-exists-check" unless="_gitconfig-exist">
<echo>Missing .gitconfig in home directory. git may have issues going to github. Mine looks like:
[user]
email = ....
name = ...
</echo>
</target>
<target name="git-completion-script" description="get the git completion script">
<exec executable="curl" dir="bin">
<arg value="https://raw.github.com/git/git/master/contrib/completion/git-completion.bash" />
<arg value="-O" />
<arg value="-L" />
</exec>
<exec executable="diff" dir="bin" failonerror="false" resultproperty="__diff_git-completion-script">
<arg value="git-completion.bash" />
<arg value="${user.home}/bin/git-completion.bash" />
</exec>
<fail message="bin/git-completion-script.bash differs from ${user.home}/bin/git-completion.bash. Do manual copy.">
<condition>
<equals arg1="${__diff_git-completion-script}" arg2="1" />
</condition>
</fail>
<exec executable="cp" dir="bin">
<arg value="-f" />
<arg value="-v" />
<arg value="git-completion.bash" />
<arg value="${user.home}/bin/git-completion.bash" />
</exec>
<exec executable="diff" dir="bin" failonerror="false" resultproperty="__diff_include-git-completion">
<arg value="include-git-completion.bash" />
<arg value="${user.home}/bin/include-git-completion.bash" />
</exec>
<fail message="bin/include-git-completion.bash differs from ${user.home}/bin/include-git-completion.bash Do manual copy.">
<condition>
<equals arg1="${__diff_include-git-completion}" arg2="1" />
</condition>
</fail>
<exec executable="cp" dir="bin">
<arg value="-f" />
<arg value="-v" />
<arg value="include-git-completion.bash" />
<arg value="${user.home}/bin/include-git-completion.bash" />
</exec>
<echo>
Add :
. bin/include-git-completion.bash
to your .bashrc
</echo>
</target>
<target name="git-svn-fetch" description="git svn fetch/clone -Dproject needs to be set">
<fail unless="project"/>
<property name="gitrootdir" value="${root-dir}"/>
<property name="local-directory" value="${gitrootdir}/${project}" />
<condition property="_dont-git-pull">
<not><available file="${local-directory}"/></not>
</condition>
<antcall target="_git-svn-fetch">
</antcall>
<condition property="_dont-git-clone">
<available file="${local-directory}"/>
</condition>
<antcall target="_git-svn-clone">
</antcall>
</target>
<target name="git-svn-pull" description="git svn pull/clone -Dproject needs to be set">
<fail unless="project"/>
<property name="gitrootdir" value="${root-dir}"/>
<property name="local-directory" value="${gitrootdir}/${project}" />
<condition property="_dont-git-pull">
<not><available file="${local-directory}"/></not>
</condition>
<antcall target="_git-svn-update">
</antcall>
<condition property="_dont-git-clone">
<available file="${local-directory}"/>
</condition>
<antcall target="_git-svn-clone">
</antcall>
</target>
<target name="_git-svn-clone" unless="_dont-git-clone" depends="_gitconfig-warning">
<fail unless="project"/>
<property name="branch" value=""/>
<property name="fail-if-fail" value="true"/>
<!-- git-url could be specified or svn-url -->
<property name="git-url" value="${svn-url}/${project}${branch}"/>
<property name="revision" value="0"/>
<!-- -s means standard svn layout w/ tags, branches and trunk. Most svn repos follow this. -->
<property name="svn-standard" value="--stdlayout"/>
<!-- Allow checking HEAD only.-->
<if>
<equals arg1="${revision}" arg2="HEAD"/>
<then>
<property name="checkout-target" value="HEAD"/>
</then>
<else>
<property name="checkout-target" value="${revision}:HEAD"/>
</else>
</if>
<echo>git svn cloning ${git-url} to Local dir: ${local-directory}</echo>
<exec executable="${git-exec}" resultproperty="_git-error-code" failonerror="${fail-if-fail}" failifexecutionfails="${fail-if-fail}">
<arg line="svn clone -r ${checkout-target} ${svn-standard} ${git-url} ${local-directory}"/>
</exec>
</target>
<target name="_git-svn-fetch" unless="_dont-git-pull">
<echo>Updating ${local-directory}</echo>
<exec dir="${local-directory}" executable="${git-exec}" failonerror="false">
<arg value="svn"/>
<arg value="fetch"/>
</exec>
</target>
<target name="_git-svn-update" depends="_git-svn-fetch" unless="_dont-git-pull">
<echo>Merging ${project}</echo>
<echo>Switching to the local master branch and then doing an svn rebase.</echo>
<exec dir="${local-directory}" executable="${git-exec}" failonerror="true">
<arg value="checkout"/>
<arg value="master"/>
</exec>
<exec dir="${local-directory}" executable="${git-exec}" failonerror="false">
<arg value="svn"/>
<arg value="rebase"/>
</exec>
</target>
<target name="update-source" description="Update the github projects. git pull all github projects">
<antcall target="git-pull">
<param name="project" value="amplafi-tools" />
</antcall>
<antcall target="_opensource-list-calls">
<param name="target-call" value="git-pull" />
<param name="target-parameter" value="project" />
</antcall>
</target>
<target name="validate-tools-opensource" depends="_java-config,_ant-config,_mvn-config,_jruby-config,css-tool-install,server-config-opensource,_update-bashrc,_fail-on-old-ant" description="Validate that the needed opensource tools have been downloaded and are the correct version">
</target>
<target name="server-config-opensource" depends="_java-config,_ant-config, _james-config-opensource">
</target>
<target name="_update-bashrc" depends="_concat-bashrc,_move-env-settings-aside" />
<target name="_set-update-bashrc">
<condition property="_update-bashrc">
<and>
<os family="unix" />
<available file="${env.settings}" />
</and>
</condition>
</target>
<target name="_ask-to-update-bashrc" depends="_set-update-bashrc" if="_update-bashrc">
<echo>
The ${env.settings} file exists.
The contents need to be in your ${user.home}/.bashrc file.
Contents to be appended:
</echo>
<concat>
<fileset file="${env.settings}" />
</concat>
<input message="Update your ${user.home}/.bashrc file with the contents of ${env.settings} [s=skip (already done)], [n=No, stop and will do manually]?" validargs="y,n,s" addproperty="_answer-to-do-update-bashrc" />
<condition property="do.update-bashrc">
<equals arg1="y" arg2="${_answer-to-do-update-bashrc}" />
</condition>
<fail message="Put the settings recorded in ${env.settings} in your environment file. And then rerun ant.">
<condition>
<equals arg1="n" arg2="${_answer-to-do-update-bashrc}" />
</condition>
</fail>
</target>
<target name="_concat-bashrc" depends="_ask-to-update-bashrc" if="do.update-bashrc">
<concat destfile="${user.home}/.bashrc" binary="true" append="true">
<fileset file="${env.settings}" />
</concat>
</target>
<target name="_move-env-settings-aside" if="_update-bashrc">
<antcall target="_backup">
<param name="_file" value="${env.settings}" />
<param name="_ext" value="txt" />
</antcall>
</target>
<target name="run-war" description="Run the self contained war">
<exec executable="java">
<arg value="-jar"/>
<arg value="${executable-war-location}"/>
</exec>
</target>
<target name="debug-war" description="Run the self contained war w/debug">
<fail unless="executable-war-location"/>
<property name="debug_port" value="8000"/>
<echo>Debug on port ${debug_port}</echo>
<exec executable="java">
<arg value="-agentlib:jdwp=transport=dt_socket,server=y,address=${debug_port}"/>
<arg value="-jar"/>
<arg value="${executable-war-location}"/>
</exec>
</target>
<!-- james -->
<target name="_james-config-opensource" depends="_validate-james,_unzip-james" />
<target name="_validate-james">
<echo>Validating James exists: ${james-home}</echo>
<condition property="_james_is_old">
<not>
<available file="${james-home}" type="dir" />
</not>
</condition>
</target>
<target name="_unzip-james" if="_james_is_old">
<echo>Getting the correct version of james.</echo>
<antcall target="_tools-unzip">
<param name="remote-tool" value="${james-tool}-bin.zip" />
<param name="_env-var" value="JAMES_HOME" />
<param name="_build.local-var" value="james-home" />
<param name="tool" value="${james-tool}" />
<param name="tool-executable" value="james" />
</antcall>
</target>
<!-- maven -->
<target name="_mvn-config" depends="_validate-mvn,_unzip-mvn">
</target>
<target name="_validate-mvn">
<echo>Validating Maven exists: ${maven-home}</echo>
<condition property="_mvn_is_old">
<not>
<available file="${maven-home}" type="dir" />
</not>
</condition>
</target>
<target name="_unzip-mvn" if="_mvn_is_old">
<echo>Getting the correct version of mvn.</echo>
<antcall target="_tools-unzip">
<param name="remote-tool" value="${maven-tool}-bin.zip" />
<param name="_env-var" value="MAVEN_HOME" />
<param name="_build.local-var" value="maven-home" />
<param name="tool" value="${maven-tool}" />
<param name="tool-executable" value="mvn" />
</antcall>
<!-- Theses are now stored in build.properties
<antcall target="_write_to_env_settings">
<param name="__env-var" value="MAVEN_MEMORY_OPTS" />
<param name="__build.local-var" value="MAVEN_MEMORY_OPTS" />
<param name="__env-value" value=""${maven-memory-opts}"" />
</antcall>
<antcall target="_write_to_env_settings">
<param name="__env-var" value="MAVEN_OPTS" />
<param name="__env-value" value="${_env-var-before-env-ref}MAVEN_MEMORY_OPTS${_env-var-after-env-ref}" />
</antcall>-->
</target>
<!-- NOTE: targets below this line must use very old ant tasks as we may be using a very old version of ant (many linux distros are very behind) -->
<!-- ant -->
<target name="_ant-config" depends="_validate-ant,_add-ant-path">
<echo>Making ant-contrib tasks available</echo>
<!-- otherwise would need: <taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${tools-dir}/ant-contrib-${ant-contrib-build}/ant-contrib-${ant-contrib-build}.jar"/> -->
<!-- we do this even though ant-contrib is checked in because we may have updated the ant-contrib release or the ant release. This avoids annoying breaks -->
<copy file="ant-contrib-${ant-contrib-build}/ant-contrib-${ant-contrib-build}.jar" tofile="apache-ant-${ant-build}/lib/ant-contrib.jar" overwrite="true"/>
</target>
<target name="_fail-on-old-ant">
<fail if="_ant_is_old" message="Your ant was an old version. Rerun ant using the new version. You MUST restart with a new shell to get your enviroment variable changes" />
</target>
<target name="_validate-ant">
<echo>Checking ant version. Expecting: ${ant-build} Got: ${ant.version}</echo>
<condition property="_ant_is_old">
<not>
<matches pattern="${ant-build}" string="${ant.version}" />
</not>
</condition>
</target>
<!-- Task writes the ant path to the env.settings file -->
<target name="_add-ant-path" unless="ant-is-on-path" depends="_is-ant-on-path">
<antcall target="_write_path_to_env_settings">
<param name="tool" value="${ant-tool}" />
</antcall>
</target>
<!-- determines if ant in the tools directory is on the environment path
Stores the answer in ${ant-is-on-path}-->
<target name="_is-ant-on-path">
<property environment="test-env" />
<condition property="ant-is-on-path">
<contains string="${test-env.PATH}" substring="${tools-dir}${file.separator}${ant-tool}${file.separator}bin" />
</condition>
</target>
<!-- downloading/unziping ant should no longer be needed, since it should be in the amplafi-tools dir and pulled from the opensource repository-->
<target name="_unzip-ant" if="_ant_is_old">
<echo>Getting the correct version of ant. Once it is downloaded, you will need to rerun ant using the downloaded version of ant.</echo>
<antcall target="_tools-unzip">
<param name="remote-tool" value="${ant-tool}-bin.zip" />
<param name="_env-var" value="ANT_HOME" />
<param name="_build.local-var" value="ant-home" />
<param name="tool" value="${ant-tool}" />
<param name="tool-executable" value="ant" />
</antcall>
<echo>Your ant was an old version. Rerun ant using the new version. See ${env.settings} file</echo>
</target>
<target name="scm-pull-tools">
<antcall target="git-pull">
<param name="project" value="amplafi-tools" />
</antcall>
</target>
<!-- PHP Unit Testing -->
<target name="phpunit-install" description="PHPUnit installation">
<echo>If pear is missing then run:
ant pear-install</echo>
<exec executable="pear">
<arg value="config-set"/>
<arg value="auto_discover"/>
<arg value="1"/>
</exec>
<exec executable="pear">
<arg value="install"/>
<arg value="pear.phpunit.de/PHPUnit"/>
</exec>
<echo>Additional optional PHPUnit code is listed at http://www.phpunit.de/manual/3.7/en/installation.html</echo>
</target>
<target name="pear-install" description="Pear installation">
<!-- TODO need to test for os version ( see below for mac only args ) -->
<!-- TODO do "pear upgrade PEAR" if pear already installed -->
<get src="http://pear.php.net/go-pear.phar" dest="bin/go-pear.phar"/>
<fail>The bin/go-pear.phar is interactive. And we cannot run it automatically. Please run:
(for Non-Mac's):
php ${tools-dir}/bin/go-pear.phar
(for Macs)
php -d detect_unicode=0 ${tools-dir}/bin/go-pear.phar
</fail>
</target>
<!-- ================Groovy============================= -->
<property name="groovy-jar" value="${mvn-repository}/org/codehaus/groovy/groovy-all/${groovy-version}/groovy-all-${groovy-version}.jar"/>
<target name="_groovy-config" depends="_groovy-validate,_groovy-download">
</target>
<target name="_groovy-validate">
<condition property="_groovy-available">
<available file="${groovy-jar}" />
</condition>
</target>
<target name="_groovy-download" unless="_groovy-available">
<echo>downloading org.codehaus.groovy:groovy-all:${groovy-version}</echo>
<antcall target="_exec">
<param name="_full-path-to-exec" value="${mvn}" />
<param name="_arg-line" value='"org.apache.maven.plugins:maven-dependency-plugin:2.3:get" "-DrepoUrl=http://download.java.net/maven/2/" "-Dartifact=org.codehaus.groovy:groovy-all:${groovy-version}"' />
</antcall>
</target>
<target name="groovy-script" depends="_groovy-config" description="General-purpose task for groovy scripts invocation.">
<fail unless="groovy-script-src" />
<fail unless="groovy-script-args-string" />
<!-- A small tutorial on using Groovy+Ant is here http://groovy.codehaus.org/The+groovy+Ant+Task -->
<!-- TODO Load groovy dynamicly, not using Ant's classpath -->
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="${groovy-jar}"/>
<echo>Executing groovy script: ${groovy-script-src}. Args: ${groovy-script-args-string}</echo>
<groovy src="${groovy-script-src}">
<arg line="${groovy-script-args-string}"/>
</groovy>
</target>
<!-- ================JRUBY============================= -->
<property name="jruby-jar" value="${mvn-repository}/org/jruby/jruby-complete/${jruby-version}/jruby-complete-${jruby-version}.jar"/>
<target name="jruby" depends="_jruby-config" description="Creates the bin directory with jruby executable. Requires mvn be run to get jruby">
</target>
<target name="_jruby-config" depends="_jruby-validation,_jruby-download,_jruby-script-generation">
<echo>${_jruby-available}</echo>
</target>
<target name="_jruby-validation">
<condition property="_jruby-available">
<and>
<available file="${jruby-jar}" />
<available file="bin/${jruby-exec}" />
</and>
</condition>
</target>
<target name="_jruby-script-generation" unless="_jruby-available">
<mkdir dir="bin" />
<echo file="bin/${jruby-exec}">
${_script-var-export} GEM_HOME=${env.GEM_HOME}
java -jar ${jruby-jar} -S ${_script-var-all-parameters}
</echo>
<chmod file="bin/${jruby-exec}" perm="ugo+rx" />
<!-- TODO: this only works under unix, does windows need something similar?-->
<antcall target="_write_path_to_env_settings">
<param name="tool" value="" />
<param name="_env-value" value="${tools-dir}${file.separator}bin" />
<param name="_env-var" value="" />
<param name="_build.local-var" value="${_build.local-var}" />
</antcall>
<antcall target="_write_to_env_settings">
<param name="__env-var" value="GEM_HOME" />
<param name="__env-value" value="${tools-dir}${file.separator}ruby${file.separator}gems" />
</antcall>
<antcall target="_write_path_to_env_settings">
<param name="tool" value="ruby${file.separator}gems" />
<param name="_env-value" value="${tools-dir}${file.separator}bin" />
<param name="_env-var" value="" />
<param name="_build.local-var" value="${_build.local-var}" />
</antcall>
</target>
<target name="_jruby-download" unless="_jruby-available">
<antcall target="_exec">
<param name="_full-path-to-exec" value="${mvn}" />
<param name="_arg-line" value='"org.apache.maven.plugins:maven-dependency-plugin:2.3:get" "-DrepoUrl=http://download.java.net/maven/2/" "-Dartifact=org.jruby:jruby-complete:${jruby-version}"' />
</antcall>
</target>
<target name="css-tool-install" depends="_compass-installation,gem-cleanup" description="installs the tools (Compass, Sass) to handle css generation">
</target>
<target name="_compass-installation" depends="_jruby-config,_sass-installation">
<antcall target="gem-install">
<param name="gem" value="compass" />
</antcall>
<echo>need to copy the file : src/main/resources/compass-config/config.rb to the root directory of the project using compass</echo>
<echo>TODO: (maybe run this command rather(?) than have a static config.rb )
compass install compass . --sass-dir "src/main/sass" --css-dir "src/main/webapp/css" --javascripts-dir "src/main/webapp/js" --images-dir "src/main/webapp/images"
also can we avoid having to set these:
export GEM_HOME=......./amplafi-tools/ruby/gems
export PATH=......./amplafi-tools/ruby/gems/bin:${PATH}
</echo>
</target>
<target name="_sass-installation" depends="_jruby-config">
<!-- runs equivalent of 'gem install sass' to download sass for use with jruby-->
<!-- XXX: This would not have to be run on every call if there is a way to tell
if sass has already been installed using jruby -->
<echo>
Installing sass:
TODO: Check: Will this work if the terminal has not been reopened to refresh environment variables?
</echo>
<antcall target="gem-install">
<param name="gem" value="sass" />
</antcall>
</target>
<target name="_csscss-installation" depends="_jruby-config">
<antcall target="gem-install">
<param name="gem" value="csscss" />
</antcall>
</target>
<target name="compass-build" depends="_compass-config" description="Uses compass to build css related files.">
<echo>${jruby} If this fails then in amplafi-tools run: "ant css-tool-install"; gem home= ${env.GEM_HOME}; compass-project-dir=${compass-project-dir}</echo>
<echo>NOTE: if you have GEM_HOME set to a different directory than the directory under amplafi-tools, you will need to manually install sass and compass
gem install sass
gem install compass
</echo>
<antcall target="_exec">
<param name="_full-path-to-exec" value="${jruby}" />
<param name="_arg-line" value='"ruby/gems/bin/compass" "compile" ${_compass-command-line}' />
</antcall>
</target>
<target name="compass-watch" depends="_compass-config" description="Uses compass to continuously watch and build css related files.">
<fail unless="compass-project-dir" />
<echo>This target will always fail, due to how you are to exit the compass watcher.</echo>
<antcall target="_exec">
<param name="_full-path-to-exec" value="${jruby}" />
<param name="_arg-line" value='"compass" "watch" ${_compass-command-line}' />
</antcall>
</target>
<target name="_compass-config" depends="jruby,_check-compass-config,_compass-set-commandline">
<property name="_compass-command-line-args" value=""/>
<fail unless="compass-project-dir" />
<property name="_compass-command-line" value=" '${compass-project-dir}' ${_compass-command-line-args} "/>
</target>
<target name="_check-compass-config">
<fail unless="compass-project-dir" />
<available file="config.rb" filepath="${compass-project-dir}" property="_sass-config-found" />
</target>
<target name="_compass-set-commandline" unless="_sass-config-found">
<!-- not certain if these default paths should really be relative -->
<property name="compass-images-dir" value="src/main/resources/img"/>
<property name="compass-javascript-dir" value="src/main/resources/js"/>
<property name="compass-css-dir" value="src/main/resources/css"/>
<property name="compass-sass-dir" value="src/main/sass"/>
<property name="_compass-command-line-args" value=" '--images-dir=${compass-images-dir}' '--javascripts-dir=${compass-javascript-dir}' '--css-dir=${compass-css-dir}' '--sass-dir=${compass-sass-dir}' --output-style nested --no-line-comments"/>
</target>
<!-- Changes the file permissions in a specified directory to remove/add write permissions. -->
<target name="_change-files-permissions-for-css-dir">
<!-- Known Issues:
* Subversion does not store file permissions. The only way that this is applied the the files is
if this target is run after downloading the files from the repository.
* All of the css files are marked readonly even if they do not have a sass equivalent, so
there is an exta step involved in editing these files.
* Workaround - rename the css file to sass and put it in the sass directory, sass will will copy
it to the css directory on next compile.-->
<echo>Changing permission in: ${_permissions-dir}</echo>
<fail unless="_permissions-dir" message="Property _permissions-dir must be set. Determins directory of which files will be affected." />
<fail unless="_permissions-set-readonly" message="Property _permissions-set-readonly must be set (true/false)" />
<fileset dir="${_permissions-dir}" id="_css-files">
<include name="**/*.css" />
</fileset>
<condition property="_permissions-unix" value="a-w" else="a+w">
<istrue value="${_permissions-set-readonly}" />
</condition>
<condition property="_permissions-windows" value="true" else="false">
<istrue value="${_permissions-set-readonly}" />
</condition>
<chmod perm="${_permissions-unix}">
<fileset refid="_css-files" />
</chmod>
<attrib readonly="${_permissions-windows}">
<fileset refid="_css-files" />
</attrib>
</target>
<!-- HACK TODO PAT: this was copied from the farreaches-common. Some of the properties are not set correctly -->
<target name="compass-ci" description="Commit css files in ${prop-web-css}">
<fail unless="prop-web-css"/>
<fail unless="prop-web"/>
<pathconvert property="_prop-web-css-files" pathsep=" ">
<fileset dir="${prop-web-css}">
<include name="**/*.css"/>
<!-- HACK: there are two files that are ignored in the css directory:
I src/main/webapp/css/bundle-guest.css
I src/main/webapp/css/bundle-member.css
These files will be added and committed if they are not excluded from this filset.-->
<exclude name="**/*bundle*.css"/>
</fileset>
<globmapper from="${prop-web}${file.separator}*" to=".${file.separator}*"/>
</pathconvert>
<echo>Adding css files.</echo>
<exec executable="${git-exec}" dir="${prop-web}" failonerror="false">
<arg value="add"/>
<arg line="${_prop-web-css-files}"/>
</exec>
<echo>Committing css files</echo>
<exec executable="${git-exec}" dir="${prop-web}" failonerror="false">
<arg value="commit"/>
<arg value="-m"/>
<arg value="Auto generated css file added/updated."/>
<arg line="${_prop-web-css-files}"/>
</exec>
</target>
<target name="gem-install" description="do a ruby gem install">
<echo>Installing ruby gem ${gem} to ${tools-dir}${file.separator}ruby${file.separator}gems</echo>
<antcall target="_exec">
<!-- could add (doubledash)rdoc but some docs have errors -->
<param name="_full-path-to-exec" value="${jruby} gem install ${gem} --install-dir ${tools-dir}${file.separator}ruby${file.separator}gems" />
</antcall>
</target>
<target name="gem-cleanup" description="do a ruby gem cleanup">
<echo>Cleaning up ${env.GEM_HOME}</echo>
<antcall target="_exec">
<param name="_full-path-to-exec" value="${jruby}" />
<param name="_arg-line" value='"gem" "cleanup"' />
</antcall>
</target>
<target name="gollum-install" description="gollum is a ruby gem that allows easy offline editing of the github based wikis">
<antcall target="gem-install">
<param name="gem" value="gollum" />
</antcall>
</target>
<target name="plovr-watch" description="Runs plovr server to compile closure on fly." depends="_closure-check-out">
<antcall target="_exec">
<param name="_full-path-to-exec" value="java" />
<param name="_arg-line" value='-jar plovr.jar serve ${plovr-config}' />
</antcall>
</target>
<target name="plovr-build" description="Compiles closure application." depends="_closure-check-out">
<antcall target="_exec">
<param name="_full-path-to-exec" value="java" />
<param name="_arg-line" value='-jar plovr.jar build ${plovr-config} > ${prod-closure-file}' />
</antcall>
</target>
<target name="_closure-check-out">
<antcall target="_exec">
<param name="_full-path-to-exec" value="svn" />
<param name="_arg-line" value='checkout http://closure-library.googlecode.com/svn/trunk/ closure-library-read-only' />
</antcall>
<antcall target="_exec">
<param name="_full-path-to-exec" value="svn" />
<param name="_arg-line" value='checkout http://closure-templates.googlecode.com/svn/trunk/ closure-templates-read-only' />
</antcall>
</target>
<!-- Run an executable on linux or a bat file on windows.
It is reccomended that you pass the ${_arg-line} parameter with quotations around each argument.
Example: <param name="_arg-line" value='"${argOne}" "${argTwo}"'/> This way if ${argOne} is a
fileName with a space in it, it will not be inadvertantly broken up into two arguments.
Just remember user input is not supported,
so commands must be non-interactive-->
<target name="_exec">
<fail unless="_full-path-to-exec" message="_full-path-to-exec is not set"/>
<!-- set _arg-line to blank if _arg-line is not set to a value. This stops the executable from getting a bad argument -->
<condition property="_arg-line" value="">
<equals arg1="${_arg-line}" arg2="$${_arg-line}" />
</condition>
<echo>Executing ${_full-path-to-exec} ${_arg-line}</echo>
<!-- Fail by default.-->
<property name="fail_on_exec_error" value="true"/>
<exec executable="cmd" osfamily="windows" failonerror="${fail_on_exec_error}">
<arg value="/c" />
<arg value="${_full-path-to-exec}" />
<arg line="${_arg-line}" />
</exec>
<exec executable="/bin/sh" osfamily="unix" failonerror="${fail_on_exec_error}">
<arg line='-c "${_full-path-to-exec} ${_arg-line}"' />
</exec>
</target>
<!-- ============================================= -->
<target name="_tools-unzip" depends="_mkdir-tools">
<!-- no longer need
<delete file="${tools-dir}/${remote-tool}" />
<get src="http://sworddance.com/tools/${remote-tool}" dest="${tools-dir}/${remote-tool}" verbose="false" /> -->
<unzip src="${tools-dir}/${remote-tool}" dest="${tools-dir}">
</unzip>
<antcall target="_write_path_to_env_settings">
<param name="_env-value" value="${tools-dir}/${tool}" />
<param name="_env-var" value="${_env-var}" />
<param name="_build.local-var" value="${_build.local-var}" />
</antcall>