-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
1006 lines (874 loc) · 36 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
<project name="local" default="auto" basedir=".">
<!--<import file="tomcat-tasks.xml"/>-->
<property environment="env"/>
<property name="contrib.dir" value="${basedir}/contrib"/>
<property name="temp.dir" value="${basedir}/temp"/>
<property name="overwriteLib" value="false"/>
<!-- ant contrib allows conditionals in ant scripts -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="java/libAnt/ant-contrib.jar" />
</classpath>
</taskdef>
<if><not><available file="build.properties" /></not>
<then><copy file="build.properties.template"
tofile="build.properties" /></then>
</if>
<property file="build.properties"/>
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): grouper.role" unless="grouper.role" />
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): ui.make.jar" unless="ui.make.jar" />
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): should.copy.context.xml.to.metainf" unless="should.copy.context.xml.to.metainf" />
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): web.xml.overwrite" unless="web.xml.overwrite" />
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): login.ui-lite.show-link" unless="login.ui-lite.show-link" />
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): ui-lite.link-from-admin-ui" unless="ui-lite.link-from-admin-ui" />
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): browser.debug.enable" unless="browser.debug.enable" />
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): browser.debug.group.enable-html-editor" unless="browser.debug.group.enable-html-editor" />
<fail message="Couldnt detect build.properties property file entry (it's probably new, copy the entry from build.properties.template): copy.grouper.jdbc.sample.drivers" unless="copy.grouper.jdbc.sample.drivers" />
<if><not><available file="tomcat-context.xml" /></not>
<then><copy file="template-tomcat-context.xml"
tofile="tomcat-context.xml" /></then>
</if>
<filter filtersfile="build.properties"/>
<property file=".lastbuild.properties"/>
<!--
In a production environment it is usual to build a clean distribution when incorporating changes,
and deploy only if the build works OK. During development it is more convenient to work in situ using an IDE.
This allows changes to be saved and become live immediately in the development environment, and also means that
files are edited under CVS control. The temptation otherwise is change files such as JSPs in their deployed location
and, hopefully, remember to copy them back to the CVS checkout area.
Some IDEs (specifically Eclipse) clean (delete) the build area before recompiling Java files. This can cause the loss
of resources that have been placed under the class folder so that they are availale to standard Java class path
lookup mechanisms. The "resources" target is designed to replace resources which have been 'lost'. This build script
allows flexibility in setting where the build directory is. If so configured, through build.properties, an external
site-specific script can be called which would allow the user to choose a build area from a menu. Otherwise a default
value is chosen.
-->
<!-- Decide what to do based on previous choices-->
<target name="auto">
<property file=".auto.properties"/>
<condition property="default.target" value="help">
<not>
<isset property="default.target"/>
</not>
</condition>
<antcall target="${default.target}"/>
</target>
<target name="endhelp">
<propertyfile file=".auto.properties">
<entry key="default.target" value="default"/>
</propertyfile>
</target>
<target name="starthelp">
<propertyfile file=".auto.properties">
<entry key="default.target" value="help"/>
</propertyfile>
</target>
<target name="default">
<antcall target="-setup"/>
</target>
<!-- only copy resources -->
<target name="resources">
<antcall target="-setup">
<param value="true" name="no.webapp"/>
</antcall>
</target>
<!-- make sure grouper dirs are set correctly -->
<target name="checkGrouper">
<available file="${grouper.jar.name}" property="grouper.file.exists" value="true" />
<if>
<not>
<isset property="grouper.file.exists" />
</not>
<then>
<fail message="Cant find grouper.jar from build.properties entry grouper.jar.name: ${grouper.jar.name}!" />
</then>
</if>
<available file="${grouper.lib.dir}/commons-lang.jar" property="grouper.lib.dir.exists" value="true" />
<if>
<not>
<isset property="grouper.lib.dir.exists" />
</not>
<then>
<fail message="Cant find grouper lib dir jars (e.g. commons-lang.jar) from build.properties entry grouper.lib.dir: ${grouper.lib.dir}!" />
</then>
</if>
<available file="${grouper.folder}/conf/grouper.properties" property="grouper.properties.file.exists" value="true" />
<if>
<not>
<isset property="grouper.properties.file.exists" />
</not>
<then>
<fail message="Cant find grouper conf dir (e.g. grouper.properties) from build.properties entry grouper.conf.dir: ${grouper.conf.dir}!" />
</then>
</if>
</target>
<target name="dev" description="copy libs to cvs webapp dir so the app can be run in dev,
not, grouper and grouper-ws libs should not be there, note that if you set your local
tomcat to grouper-ws-home/webapp is should run locally. Note this should only need
to be done once (unless non grouper jars change)" depends="checkGrouper">
<mkdir dir="${basedir}/webapp/WEB-INF/lib" />
<delete dir="${basedir}/webapp/WEB-INF/lib" includes="*.jar" />
<copy todir="${basedir}/webapp/WEB-INF/lib">
<fileset dir="${basedir}/java/lib" includes="*.jar" />
<fileset dir="${grouper.lib.dir}/../jdbcSamples">
<include name="*.jar"/>
</fileset>
<fileset dir="${grouper.lib.dir}">
<include name="*.jar"/>
<!-- this should be a linked source dir -->
<exclude name="grouper*.jar"/>
</fileset>
</copy>
<copy todir="${basedir}/webapp/WEB-INF/lib">
<fileset dir="${grouper.lib.dir}">
<include name="grouperClient.jar"/>
</fileset>
</copy>
<copy todir="${basedir}/webapp/WEB-INF">
<fileset file="${dist.home}/${webapp.name}/WEB-INF/web.xml" />
</copy>
</target>
<!-- only copy resources - and restart webapp-->
<target name="niceres">
<antcall target="check-and-fix-tomcat-tasks"/>
<antcall target="-setup">
<param value="true" name="no.webapp"/>
</antcall>
<ant antfile="tomcat-tasks.xml" target="restart"/>
</target>
<!--
Clean build directory before building
-->
<target name="clean">
<antcall target="-setup">
<param name="build.clean" value="true"/>
</antcall>
</target>
<!--
Do not clean build directory before building
-->
<target name="noclean">
<antcall target="-setup">
<param name="build.clean" value="false"/>
</antcall>
</target>
<!--
Build into dist.home
-->
<target name="dist">
<property name="deploy.docbase" value="${webapp.name}"/>
<antcall target="-setup">
<param name="build.dist" value="true"/>
<param name="build.clean" value="true"/>
</antcall>
<echo>****************************************************</echo>
<echo>** The Grouper UI will fail to start if the user **</echo>
<echo>** which your application server runs as does not **</echo>
<echo>** have permission to write to the log files that **</echo>
<echo>** are configured in log4j.properties. See **</echo>
<echo>** build.properties for more information **</echo>
<echo>****************************************************</echo>
</target>
<target name="test">
<path id="dist.class.path">
<pathelement location="${last.webapp.folder}/WEB-INF/classes"/>
<!-- Make available jar files that Grouper needs -->
<fileset dir="${last.webapp.folder}/WEB-INF/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${ui.folder}/contrib">
<include name="**/*.jar"/>
</fileset>
</path>
<java classname="edu.internet2.middleware.grouper.ui.util.TestWebappSources"
classpathref="dist.class.path" outputproperty="testOutput" />
<echo message="${testOutput}"/>
</target>
<!--
Build into dist.home and then make a war file
-->
<target name="war">
<property name="deploy.docbase" value="${webapp.name}"/>
<antcall target="dist">
<param name="build.war" value="true"/>
</antcall>
</target>
<!--
stop webapp, build and start webapp
-->
<target name="nice">
<antcall target="check-and-fix-tomcat-tasks"/>
<antcall target="-setup">
<param name="build.stop.tomcat" value="true"/>
</antcall>
<antcall target="-doStart"/>
</target>
<!--
Clean build directory, stop webapp, build and start webapp
-->
<target name="niceclean">
<antcall target="check-and-fix-tomcat-tasks"/>
<antcall target="-setup">
<param name="build.clean" value="true"/>
<param name="build.stop.tomcat" value="true"/>
</antcall>
<antcall target="-doStart"/>
</target>
<target name="-dist-grouper" unless="grouper.is.available">
<echo message="Building Grouper API"/>
<ant dir="${grouper.folder}" target="dist"/>
</target>
<!--
Resources come from various sources:
1) Grouper itself relies on properties and xml configuration files to be available on the class path.
2) The ui uses resources for Internationalisation and other configuration
3) Implementing sites may have additional resources e.g. configuration files for a Subject implementation.
-->
<target name="-resources" unless="no.resources">
<echo message="In resources - Build folder = ${webapp.folder}"/>
<!-- Core configuration settings that must be present -->
<fail unless="webapp.folder">webapp.folder must be set</fail>
<fail unless="grouper.folder">grouper.folder must be set</fail>
<fail unless="ui.folder">ui.folder must be set</fail>
<if>
<equals arg1="true" arg2="${grouper.compile.api}"/>
<then>
<available file="${grouper.folder}/src/grouper" property="grouper.is.available"/>
<fail unless="grouper.is.available">grouper.compile.api is true so must have grouper source files i.e. cannot use this option with
a binary distribution</fail>
</then>
<else>
<available file="${grouper.folder}/dist/lib/grouper.jar" property="grouper.is.available"/>
</else>
</if>
<available file="${grouper.folder}/dist/lib/grouper.jar" property="grouper.is.available"/>
<antcall target="-dist-grouper"/>
<available file="${grouper.folder}/dist/lib/grouper.jar" property="grouper.is.now.available"/>
<if>
<not><equals arg1="true" arg2="${grouper.compile.api}"/></not>
<then>
<fail unless="grouper.is.now.available" message="${grouper.folder}/dist/lib/grouper.jar does not exist. You must
build and configure Grouper before running this script"/>
</then>
</if>
<echo message="Creating ${webapp.folder}"/>
<mkdir dir="${webapp.folder}"/>
<mkdir dir="${webapp.class.folder}"/>
<mkdir dir="${webapp.folder}/WEB-INF/lib"/>
<echo message="Copying Grouper configuration files to ${webapp.class.folder}"/>
<copy todir="${webapp.class.folder}" overwrite="true">
<fileset dir="${grouper.folder}/conf">
<exclude name="*.example.*"/>
</fileset>
</copy>
<!-- Allow local log4j.properties -->
<condition property="local.log4j">
<equals trim="true" arg2="true" arg1="${use.local.log4j}"/>
</condition>
<antcall target="-local-log4j"/>
<antcall target="-fix-grouper-home" />
<echo message="Copying ui resources to ${webapp.class.folder}/resources"/>
<mkdir dir="${webapp.class.folder}/resources"/>
<copy todir="${webapp.class.folder}/resources" overwrite="true" filtering="on">
<fileset dir="${ui.folder}/conf/resources"/>
</copy>
<!-- If configured call a site specific build script -->
<antcall target="-additional-build">
<param name="target" value="resources"/>
</antcall>
<available file="optional-conf" property="optional.conf"/>
<!-- If available do further configuration -->
<antcall target="-optional-conf"/>
</target>
<target name="-fix-grouper-home" if="replace.grouper.home">
<if>
<matches string="${grouper.folder}" pattern="^(\w:|/).*"/>
<then>
<echo>Attempting to replace grouper.home with ${grouper.folder}/</echo>
<replace file="${webapp.class.folder}/log4j.properties" value="${grouper.folder}/">
<replacetoken><![CDATA[${grouper.home}]]></replacetoken>
</replace>
</then>
<else>
<path id="temp.path">
<pathelement location="${basedir}"/>
</path>
<pathconvert targetos="unix" property="base.dir" refid="temp.path"/>
<echo>Attempting to replace grouper.home with ${base.dir}/${grouper.folder}/</echo>
<replace file="${webapp.class.folder}/log4j.properties" value="${base.dir}/${grouper.folder}/">
<replacetoken><![CDATA[${grouper.home}]]></replacetoken>
</replace>
</else>
</if>
</target>
<!-- Copy local log4j.properties -->
<target name="-local-log4j" if="local.log4j">
<copy filtering="true" file="${basedir}/log4j.properties" todir="${webapp.class.folder}" overwrite="true"/>
</target>
<!--
Copy in any additional config files
-->
<target name="-optional-conf" if="optional.conf">
<echo message="Copying and filtering optional configurations"/>
<touch file="build.tokens"/>
<filter filtersfile="build.tokens"/>
<copy todir="${webapp.class.folder}" filtering="on" overwrite="true">
<fileset dir="optional-conf"/>
</copy>
</target>
<!--
Let user choose where to build
-->
<target name="-choose-webapp" if="webapp.do.choose.build">
<echo message="Calling site specific script to choose build folder - '${webapp.choose.build}'"/>
<ant antfile="${webapp.choose.build}" target="choose"/>
</target>
<!--
Builds the entire webapp
-->
<target name="-webapp" unless="no.webapp" >
<delete dir="${temp.dir}"/>
<mkdir dir="${temp.dir}"/>
<mkdir dir="${dist.home}"/>
<path id="ui.class.path">
<!-- Make available jar files that Grouper needs -->
<fileset dir="${grouper.folder}/lib">
<include name="**/*.jar"/>
</fileset>
<!-- Make available jar files the UI needs -->
<fileset dir="${ui.folder}/java/lib">
<include name="**/*.jar"/>
</fileset>
<!-- Make available jar files already placed in the build folder -
may happen when additional-build called -->
<fileset dir="${webapp.folder}/WEB-INF/lib">
<include name="**/*.jar"/>
<exclude name="**/grouper.jar"/>
<exclude name="**/grouper-ui.jar"/>
</fileset>
<!-- make available any classes / resources already placed in the build folder -->
<pathelement location="${webapp.class.folder}"/>
<fileset dir="${grouper.folder}/dist/lib">
<!-- Last, but not least, make Grouper API available -->
<include unless="grouper.compile.api" name="grouper.jar"/>
</fileset>
<fileset dir="${ui.folder}/contrib">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- don't want grouper-ui.jar when compiling ui source - but do when running ui code or compiling dependent (custom) code -->
<path id="ui.class.path.for.run">
<path refid="ui.class.path"/>
<fileset dir="${webapp.folder}/WEB-INF/lib">
<include if="ui.make.jar" name="grouper-ui.jar"/>
</fileset>
</path>
<antcall target="-compileGrouper"/>
<!-- Compile ui code - mostly Struts actions -->
<if><equals arg1="${ui.make.jar}" arg2="true"/>
<then>
<mkdir dir="${temp.dir}/jarBin"/>
<property name="ui.javac.dest" value="${temp.dir}/jarBin"/>
</then>
<else>
<property name="ui.javac.dest" value="${webapp.folder}/WEB-INF/classes"/>
</else>
</if>
<javac destdir="${ui.javac.dest}" classpathref="ui.class.path"
debuglevel="${debug.level}" debug="true" target="1.5">
<src path="${ui.folder}/contrib/penn-auth/java/src"/>
<src path="${ui.folder}/contrib/struts-patch/java/src"/>
<src path="${ui.folder}/contrib/yale-cas-auth/java/src"/>
<src path="${ui.folder}/java/src" />
</javac>
<if><equals arg1="${ui.make.jar}" arg2="true"/>
<then>
<jar file="${webapp.folder}/WEB-INF/lib/grouper-ui.jar">
<fileset dir="misc">
<include name="META-INF/*" />
</fileset>
<fileset dir="${temp.dir}/jarBin" />
<fileset dir="${ui.folder}/java/src" />
</jar>
</then>
</if>
<!-- Call any site specific build script. This may be used to introduce site specific Struts action,
local Subject implementations etc -->
<antcall target="-additional-build">
<param name="target" value="webapp"/>
<reference refid="ui.class.path.for.run"/>
</antcall>
<!-- Make all necessary jar files available to the webapp itself -->
<copy todir="${webapp.folder}/WEB-INF/lib" overwrite="${overwiteLib}">
<fileset dir="${grouper.folder}/dist/lib">
<include unless="grouper.compile.api" name="grouper.jar"/>
</fileset>
<fileset dir="${grouper.folder}/lib/grouper">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${grouper.folder}/lib/custom">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${ui.folder}/java/lib">
<include name="**/*.jar"/>
<exclude name="servlet.jar"/>
</fileset>
</copy>
<if>
<equals arg1="true" arg2="${copy.grouper.jdbc.sample.drivers}"/>
<then>
<copy todir="${webapp.folder}/WEB-INF/lib" overwrite="${overwiteLib}">
<fileset dir="${grouper.folder}/lib/jdbcSamples">
<include name="**/*.jar"/>
</fileset>
</copy>
</then>
</if>
<!-- If working on core Grouper UI would expect developers to build in situ - so no need to copy web content! -->
<condition property="webapp-folder-is-build-folder">
<equals arg1="${webapp.folder}" arg2="${ui.folder}/webapp"/>
</condition>
<antcall target="-copyContent"/>
<echo message="Processing web.xml"/>
<copy file="${ui.folder}/webapp/WEB-INF/web.core-filters.xml" tofile="${temp.dir}/99.web.core-filters.xml"/>
<path id="web.xml.files">
<fileset dir="${temp.dir}">
<include name="**/*.xml"/>
</fileset>
</path>
<property name="web.xmls" refid="web.xml.files"/>
<condition property="web.xmls.isempty">
<equals arg1="${web.xmls}" arg2=""/>
</condition>
<echo message="web.xmls.isempty=:${web.xmls.isempty}:"/>
<antcall target="-merge-xmls">
<reference refid="ui.class.path.for.run" torefid="merge.class.path"/>
</antcall>
<antcall target="-copy-core-web-xml"/>
<antcall target="-copyContextXmlToMetaInf"/>
<condition property="copyToTomcat" value="true">
<and>
<isset property="deploy.copy.context.xml"/>
<available file="${deploy.context.dir}" type="dir"/>
<available file="./${deploy.context.xml}" type="file"/>
</and>
</condition>
<antcall target="-copyContextXmlToTomcat"/>
</target>
<target name="-copyContextXmlToMetaInf" if="deploy.context.xml">
<if>
<equals arg1="true" arg2="${should.copy.context.xml.to.metainf}"/>
<then>
<filter token="deploy.docbase" value="${deploy.docbase}"/>
<filter token="deploy.context.path" value="${deploy.context.path}"/>
<copy file="${deploy.context.xml}" tofile="${webapp.folder}/META-INF/context.xml" filtering="true" overwrite="true"/>
</then>
</if>
</target>
<target name="-copyContextXmlToTomcat" if="copyToTomcat">
<if>
<equals arg1="true" arg2="${should.copy.context.xml.to.metainf}"/>
<then>
<filter token="deploy.docbase" value="${deploy.docbase}"/>
<filter token="deploy.context.path" value="${deploy.context.path}"/>
<copy file="${deploy.context.xml}" tofile="${deploy.context.dir}/${webapp.name}.xml" filtering="true" overwrite="true"/>
</then>
</if>
</target>
<!--
Merge any xml files in temp directory with web.core.xml
-->
<target name="-merge-xmls" unless="web.xmls.isempty">
<if>
<or>
<not><available file="webapp/WEB-INF/web.xml" /></not>
<not><equals arg1="${web.xml.overwrite}" arg2="false" /></not>
</or>
<then>
<echo message="temp.dir : ${temp.dir}" />
<echo message="final.web.xmls : ${final.web.xmls}" />
<echo message="ui.folder : ${ui.folder}" />
<echo message="webapp.folder : ${webapp.folder}" />
<copy file="${ui.folder}/webapp/WEB-INF/web.core.xml" tofile="${temp.dir}/50.web.core.xml" filtering="true"/>
<copy file="${ui.folder}/webapp/WEB-INF/web.ajax.xml" tofile="${temp.dir}/60.web.ajax.xml" filtering="true"/>
<path id="final.web.xml.files">
<fileset dir="${temp.dir}">
<include name="**/*.xml"/>
</fileset>
</path>
<property name="final.web.xmls" refid="final.web.xml.files"/>
<java classname="edu.internet2.middleware.grouper.ui.util.MergeWebXmls" classpathref="merge.class.path" outputproperty="mergeOutput" resultProperty="result">
<arg value="${temp.dir}"/>
<arg value="${final.web.xmls}"/>
<arg value="${ui.folder}/web-xml-merge.xsl"/>
<arg value="${ui.folder}/web-xml-merge-tags.xml"/>
<arg value="${webapp.folder}/WEB-INF/web.xml"/>
</java>
<echo message="${mergeOutput}"/>
<echo message="Result: ${result}"/>
<condition property="failed">
<not>
<equals arg1="0" arg2="${result}"/>
</not>
</condition>
</then>
<else>
<echo message="web.xml exists and web.xml.overwrite=false, so NOT rebuilding web.xml. Delete web.xml to force a rebuild" />
</else>
</if>
<fail if="failed">Something went wrong processing web.xmls - check output for details</fail>
<!-- copy file="webapp/WEB-INF/web.xml"
tofile="${webapp.folder}/WEB-INF/web.xml" /-->
</target>
<!--
If nothing to merge just copy core file
-->
<target name="-copy-core-web-xml" if="web.xmls.isempty">
<copy file="${ui.folder}/webapp/WEB-INF/web.core.xml" tofile="${webapp.folder}/WEB-INF/web.xml" overwrite="true" filtering="true"/>
</target>
<!--
If configured, compile grouper source -handy if changing both code sets
-->
<target name="-compileGrouper" if="grouper.compile.api">
<echo message="Compiling the Grouper api"/>
<javac srcdir="${grouper.folder}/src/grouper" destdir="${webapp.class.folder}" classpathref="ui.class.path" debuglevel="${debug.level}" debug="true"/>
<copy todir="${webapp.class.folder}">
<fileset dir="${grouper.folder}/src/grouper">
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<!--
Copy static web content unless working in situ
-->
<target name="-copyContent" unless="webapp-folder-is-build-folder">
<echo message="Copying core UI files to ${webapp.folder}"/>
<copy todir="${webapp.folder}">
<fileset dir="${ui.folder}/webapp">
<exclude name="WEB-INF/classes/**/*.*"/>
<exclude name="WEB-INF/lib/**/*.*"/>
</fileset>
</copy>
</target>
<!--
Hook to allow sites to build in their own customisations
-->
<target name="-additional-build" if="additional.build">
<echo message="Calling site specific build script - '${additional.build}' - target=${target}"/>
<dirname property="additional.build.dir" file="${additional.build}"/>
<!-- In trying to debug why ui.class.path was not inherited the problem went away when the line below was added for debugging!-->
<property name="uicp" refid="ui.class.path.for.run"/>
<ant antfile="${additional.build}" target="${target}" inheritrefs="true" dir="${additional.build.dir}"/>
</target>
<target name="-war" if="build.war">
<delete file="${dist.home}/${webapp.name}.war"/>
<fixcrlf srcdir="${dist.home}/${webapp.name}/WEB-INF/bin" eol="unix" includes="*.sh" />
<fixcrlf srcdir="${dist.home}/${webapp.name}/WEB-INF/bin" eol="dos" includes="*.bat" />
<chmod dir="${dist.home}/${webapp.name}/WEB-INF/bin" includes="*.sh,*.bat" perm="ugo+rx"/>
<copy file="${dist.home}/${webapp.name}/WEB-INF/bin/gsh.sh" tofile="${dist.home}/${webapp.name}/WEB-INF/bin/gsh" />
<fixcrlf srcdir="${dist.home}/${webapp.name}/WEB-INF/bin" eol="unix" includes="gsh" />
<chmod dir="${dist.home}/${webapp.name}/WEB-INF/bin" includes="gsh" perm="ugo+rx"/>
<echo message="Creating ${dist.home}/${webapp.name}.war"/>
<jar destfile="${dist.home}/${webapp.name}.war" basedir="${dist.home}/${webapp.name}"/>
</target>
<!--
Work out what we are doing
-->
<target name="-setup">
<!-- If needed make sure we have a distribution directory-->
<condition property="dist.home" value="${basedir}/../dist">
<and>
<not>
<isset property="dist.home"/>
</not>
<isset property="build.dist"/>
</and>
</condition>
<!-- If we are distributing force webapp.folder value-->
<condition property="webapp.folder" value="${dist.home}/${webapp.name}">
<isset property="build.dist"/>
</condition>
<!-- Only choose if we don't have webapp.folder and we are configured to-->
<condition property="webapp.do.choose.build">
<and>
<not>
<isset property="webapp.folder"/>
</not>
<isset property="webapp.choose.build"/>
</and>
</condition>
<!--Choose if we must-->
<antcall target="-choose-webapp"/>
<!-- Can't propagate properties back - so put in file and load-->
<property file="choice.properties"/>
<!-- We don't have a webapp.folder - use the default-->
<condition property="webapp.do.default.build">
<not>
<isset property="webapp.folder"/>
</not>
</condition>
<!-- Set default if we must-->
<condition property="webapp.folder" value="${default.webapp.folder}">
<isset property="webapp.do.default.build"/>
</condition>
<condition property="webapp.folder.cleanable" value="${default.webapp.folder.cleanable}">
<and>
<isset property="webapp.do.default.build"/>
<istrue value="${default.webapp.folder.cleanable}"/>
</and>
</condition>
<propertyfile file=".lastbuild.properties">
<entry key="last.webapp.folder" value="${webapp.folder}"/>
</propertyfile>
<condition property="webapp.class.folder" value="${webapp.folder}/WEB-INF/classes">
<not>
<isset property="webapp.class.folder"/>
</not>
</condition>
<!-- Where do we put the context.xml -->
<condition property="deploy.copy.context.xml" value="true">
<not>
<isset property="deploy.docbase"/>
</not>
</condition>
<!-- make sure we know where docbase is-->
<condition property="deploy.docbase" value="${webapp.folder}">
<not>
<isset property="deploy.docbase"/>
</not>
</condition>
<!-- Determine if we should do a clean build-->
<condition property="do.clean">
<and>
<istrue value="${build.clean}"/>
<!-- Only if selected-->
<or>
<and>
<not>
<isset property="build.dist"/>
</not>
<isset property="webapp.folder.cleanable"/>
</and>
<isset property="build.dist"/>
</or>
</and>
</condition>
<echo message="In setup - do.clean = ${do.clean}
cleanable=${webapp.folder.cleanable}"/>
<!--stop if we must-->
<antcall target="-doStop"/>
<!--Clean if we must-->
<antcall target="-doCleanWebappClassFolder"/>
<antcall target="-doClean"/>
<antcall target="-resources"/>
<antcall target="-webapp"/>
<antcall target="-html"/>
<antcall target="-war"/>
<antcall target="-web"/>
</target>
<!--
Actually delete previous build
-->
<target name="-doClean" if="do.clean">
<echo message="Removing ${webapp.folder}"/>
<delete dir="${webapp.folder}"/>
<delete dir="${dist.home}"/>
<delete dir="${temp.dir}"/>
<mkdir dir="${temp.dir}"/>
</target>
<!--
Actually delete previous build class folder
-->
<target name="-doCleanWebappClassFolder" if="build.clean">
<echo message="Removing ${webapp.class.folder}"/>
<delete dir="${webapp.class.folder}"/>
</target>
<!--
Stop tomcat
-->
<target name="-doStop" if="build.stop.tomcat">
<ant antfile="tomcat-tasks.xml" target="execWithCheckExist">
<property value="execStop" name="tomcat.action"/>
</ant>
</target>
<!--
Start tomcat
-->
<target name="-doStart" >
<ant antfile="tomcat-tasks.xml" target="execWithCheckExist">
<property value="execStart" name="tomcat.action"/>
</ant>
</target>
<!--
Explain options to user
-->
<target name="help">
<condition property="last.target" value="exit">
<not><isset property="last.target"/></not>
</condition>
<echo>Please ensure you have read the documentation - </echo>
<echo>and created a build.properties file based on the template provided</echo>
<echo></echo>
<echo>The following targets are available - type the appropriate name:</echo>
<echo></echo>
<echo>1) default </echo>
<echo> Simply builds, without cleaning, to the default.webapp.folder</echo>
<echo>2) nice</echo>
<echo> Attempts to stop the Tomcat webapp before building. </echo>
<echo> Attempts to start the webappp afterwards</echo>
<echo>3) clean</echo>
<echo> Always removes the webapp.class.folder. May remove the </echo>
<echo> webapp.folder if webapp.folder.cleanable=true</echo>
<echo> On Windows this may fail as Windows tends to lock files</echo>
<echo>4) niceclean</echo>
<echo> Combination of nice and clean </echo>
<echo>5) dist</echo>
<echo> Cleans and then builds to subfolder of dist.home</echo>
<echo>6) war</echo>
<echo> Does dist and then makes a WAR file</echo>
<echo>7) resources</echo>
<echo> Does not compile Java classes but 'refreshes' resources in</echo>
<echo> webapp.class.folder</echo>
<echo>8 niceres</echo>
<echo> Does not compile Java classes but 'refreshes' resources in</echo>
<echo> webapp.class.folder and restarts webapp</echo>
<echo>9) help</echo>
<echo> Displays this menu</echo>
<echo>10) endhelp</echo>
<echo> Subsequent invocation of ant with no target will run </echo>
<echo> 'default' rather than help</echo>
<echo>11) starthelp</echo>
<echo> Subsequent invocation of ant with no target will run 'help' </echo>
<echo>12) html</echo>
<echo> Generate Javadoc - you must have done a 'default' build previously</echo>
<echo>13) web</echo>
<echo> Copy the docroot to the dist dir</echo>
<echo>14) dev</echo>
<echo> Copy libs to webapp dir if running from checkedout directory during development</echo>
<echo>15) exit</echo>
<echo> Exit this menu without executing another target</echo>
<echo></echo>
<input message="Make your choice (${last.target})>" defaultvalue="${last.target}" addproperty="do.this"/>
<propertyfile file=".lastbuild.properties">
<entry key="last.target" value="${do.this}"/>
</propertyfile>
<antcall target="${do.this}"/>
</target>
<target name="exit">
<echo message="OK exit selected - so quitting"/>
</target>
<target name="props">
<echo message="webapp.name=${webapp.name}"/>
<echo message="basedir=${basedir}"/>
<echo message="deploy.context.path=${deploy.context.path}"/>
</target>
<target name="html">
<antcall target="-setup">
<param name="make.javadoc" value="true"/>
<param name="no.webapp" value="true"/>
<param name="no.resources" value="true"/>
</antcall>
</target>
<target name="web">
<antcall target="-setup">
<param name="make.web" value="true"/>
<param name="no.webapp" value="true"/>
<param name="no.resources" value="true"/>
</antcall>
</target>
<!-- just copy the docroot to the docroot to ease ui development -->
<target name="-web" if="make.web" description="copy docroot to dist">
<copy todir="${dist.home}/${webapp.name}">
<fileset dir="${ui.folder}/webapp">
<exclude name="WEB-INF/classes/**/*.*"/>
<exclude name="WEB-INF/lib/**/*.*"/>
</fileset>
</copy>
</target>
<target name="-html" if="make.javadoc" description="generate public api docs" >
<!-- Let's be sure we clear out old cruft first... -->
<delete dir="doc/api" />
<path id="ui.class.path">
<!-- Make available jar files that Grouper needs -->
<fileset dir="${grouper.folder}/lib">
<include name="**/*.jar"/>
</fileset>
<!-- Make available jar files the UI needs -->
<fileset dir="${ui.folder}/java/lib">
<include name="**/*.jar"/>
</fileset>
<!-- Last, but not least, make Grouper API available -->
<pathelement location="${grouper.folder}/dist/lib/grouper.jar"/>
</path>
<property name="cp" refid="ui.class.path"/>
<available file="${grouper.folder}/src/grouper" property="exists.grouper.src"/>
<antcall target="-create-if-absent-grouper-src"/>
<antcall target="-html-with-subject" inheritrefs="true"/>
<antcall target="-html-without-subject" inheritrefs="true"/>
<antcall target="-remove-if-created-grouper-src"/>
</target>
<target name="-create-if-absent-grouper-src" unless="exists.grouper.src">
<mkdir dir="${grouper.folder}/src/grouper"/>
</target>
<target name="-remove-if-created-grouper-src" unless="exists.grouper.src">
<delete dir="${grouper.folder}/src/grouper"/>
</target>
<target name="-html-with-subject" if="subject.folder">
<javadoc
maxmemory="256m"
destdir="doc/api"
classpathref="ui.class.path"
access="public"
>
<packageset dir="java/src" defaultexcludes="yes">
<include name="edu/internet2/middleware/grouper/**"/>
</packageset>
<packageset dir="${grouper.folder}/src/grouper" defaultexcludes="yes">
<include name="edu/internet2/middleware/grouper/**"/>
</packageset>
<packageset dir="${subject.folder}/src" defaultexcludes="yes">
<include name="edu/internet2/middleware/**"/>
</packageset>
<link href="http://struts.apache.org/1.2.x/api/"/>
<link href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api"/>
<link href="http://java.sun.com/j2se/1.5.0/docs/api"/>
</javadoc>
</target>
<target name="-html-without-subject" unless="subject.folder">
<javadoc
destdir="doc/api"
classpathref="ui.class.path"
access="public"
>
<packageset dir="java/src" defaultexcludes="yes">
<include name="edu/internet2/middleware/grouper/**"/>
</packageset>
<packageset dir="${grouper.folder}/src/grouper" defaultexcludes="yes">
<include name="edu/internet2/middleware/grouper/**"/>
</packageset>
<link href="http://struts.apache.org/1.2.x/api/"/>
<link href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api"/>
<link href="http://java.sun.com/j2se/1.4.2/docs/api"/>
</javadoc>
</target>
<!-- Make life easy for user-->
<target name="check-and-fix-tomcat-tasks">
<available property="catalina-ant.available" classname="org.apache.catalina.ant.DeployTask"/>
<antcall target="-ask-fix-catalina-ant"/>
</target>
<target name="-ask-fix-catalina-ant" unless="catalina-ant.available">
<input message="catalina-ant.jar is not available. Copy to ${user.home}/.ant/lib (y|n)?>" defaultvalue="n" addproperty="copy-catalina-ant"/>
<condition property="do.fix">
<equals arg1="y" arg2="${copy-catalina-ant}"/>
</condition>
<antcall target="-fix-catalina-ant"/>
<fail unless="do.fix" message="Please add catalina-ant.jar to ${user.home}/.ant/lib before running a 'nice' task"/>
</target>
<target name="-fix-catalina-ant" if="do.fix">
<mkdir dir="${user.home}/.ant/lib"/>