-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild-railo.xml
1661 lines (1584 loc) · 75.2 KB
/
build-railo.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="build-railo" basedir="./" xmlns:antcontrib="antlib:net.sf.antcontrib">
<dirname property="build-railo.basedir" file="${ant.file.build-railo}" />
<property file="${build-railo.basedir}/build-railo.properties" />
<target name="railo.requires">
<antcontrib:if>
<or>
<equals arg1="${railo.patch.version}" arg2="" />
<equals arg1="${railo.patch.version}" arg2="$${railo.patch.version}" />
</or>
<then/>
<else>
<antcontrib:var name="railo.version" value="${railo.patch.version}" />
</else>
</antcontrib:if>
<version-splitter property="railo.version" version="${railo.version}"/>
<echo message="Railo version: Major ${railo.version.major} Minor ${railo.version.minor} Build ${railo.version.build} Revision ${railo.version.revision}"/>
<property name="ext.railo.dir" value="${ext.dir}/railo/${railo.version.major}" />
<property name="ext.railo.war" value="${ext.railo.dir}/railo-${railo.version}.war" />
<antcontrib:var name="cfml.engine.war" value="${ext.railo.war}" />
<antcontrib:if>
<available file="${ext.railo.war}" /><then/>
<else>
<dependency groupId="org.getrailo" artifactId="railo" version="${railo.version}" type="jar" dest="${war.target.dir}/WEB-INF/lib" unzip="false" />
<dependency groupId="org.getrailo" artifactId="railo.optional" version="${railo.version}" type="pom" dest="${war.target.dir}/WEB-INF/lib" unzip="false" />
<mvn-get groupId="org.getrailo" artifactId="railo-web-xml" version="${railo.version}" type="xml" tofile="${war.target.dir}/WEB-INF/web.xml" />
<zip destfile="${ext.railo.war}" basedir="${war.target.dir}">
<fileset dir="${war.target.dir}" />
</zip>
</else>
</antcontrib:if>
</target>
<target name="railo.war.init" depends="railo.requires">
<unzip src="${ext.railo.war}" dest="${war.target.dir}"/>
<antcontrib:runtarget target="railo.war.config" />
</target>
<target name="railo.war.config">
<property name="extracted" location="${java.io.tmpdir}/extracted"/>
<mkdir dir="${extracted}"/>
<loadfile property="railo.web.mxl" srcfile="${war.target.dir}/WEB-INF/web.xml" />
<antcontrib:propertyregex override="yes" property="railo.web.mxl" input="${railo.web.mxl}" regexp="<web-app[^>]+>" replace="<web-app>" global="true" />
<echo file="${war.target.dir}/WEB-INF/web.xml" message="${railo.web.mxl}" />
<available property="extract.railo.jar" value="${war.target.dir}/WEB-INF/lib/railo-${railo.version}.jar"
file="${war.target.dir}/WEB-INF/lib/railo-${railo.version}.jar"/>
<available property="extract.railo.jar" value="${war.target.dir}/WEB-INF/lib/railo.jar"
file="${war.target.dir}/WEB-INF/lib/railo.jar"/>
<echo message="${extract.railo.jar}" />
<echo message="${war.target.dir}" />
<unzip src="${extract.railo.jar}" dest="${extracted}">
<patternset>
<include name="core/core.rc"/>
</patternset>
</unzip>
<unzip src="${extracted}/core/core.rc" dest="${extracted}">
<patternset>
<include name="resource/config/**"/>
</patternset>
</unzip>
<copy file="${extracted}/resource/config/server.xml" tofile="${railo.server.config.file}" overwrite="true" />
<copy file="${extracted}/resource/config/web.xml" tofile="${railo.web.config.dir}/railo-web.xml.cfm" overwrite="true" />
<delete dir="${extracted}"/>
<antcontrib:if>
<equals arg1="${server.sharedlibs}" arg2="true" />
<then>
<delete>
<fileset dir="${war.target.dir}/WEB-INF">
<include name="lib/**"/>
<exclude name="**/lib/railo-server/**"/>
<exclude name="**/WEB-INF/railo/**"/>
</fileset>
</delete>
</then>
</antcontrib:if>
<property name="war.keep.welcome" value="false" />
<antcontrib:if>
<equals arg1="${war.keep.welcome}" arg2="false" />
<then>
<delete>
<fileset dir="${war.target.dir}">
<exclude name="WEB-INF/**"/>
</fileset>
</delete>
</then>
</antcontrib:if>
<!-- remove railo file servlet as it causes trouble -->
<xmltask source="${war.target.dir}/WEB-INF/web.xml" dest="${war.target.dir}/WEB-INF/web.xml">
<xmlcatalog refId="commonDTDs" />
<remove path="web-app/servlet[servlet-class/text()='railo.loader.servlet.FileServlet']" />
<remove path="web-app/servlet-mapping[servlet-name/text()='FileServlet']" />
</xmltask>
<!-- set the WAR relative railo config dirs for server and web -->
<relpath from="${war.target.dir}" to="${railo.web.config.dir}" property="railo.initparam.web-config" />
<relpath from="${war.target.dir}" to="${railo.server.config.dir}" property="railo.initparam.server-config" />
<xmltask source="${war.target.dir}/WEB-INF/web.xml" dest="${war.target.dir}/WEB-INF/web.xml">
<xmlcatalog refId="commonDTDs" />
<replace path="web-app/servlet[servlet-class/text()='railo.loader.servlet.CFMLServlet']/init-param[param-value/text()='/WEB-INF/railo/']/param-value/text()" withText="{web-root-directory}/${railo.initparam.web-config}" />
<!-- TODO: railo-server-root must be an absolute path if set at all, basically.
<insert path="web-app/servlet[servlet-class/text()='railo.loader.servlet.CFMLServlet']" position="under">
<![CDATA[<init-param><param-name>railo-server-root</param-name><param-value>${railo.initparam.server-config}</param-value></init-param>]]></insert>
-->
</xmltask>
<!-- needed if deployed to jboss 6
<mkdir dir="${ext.dir}/jboss" />
<requires-ext-file file="${ext.dir}/jboss/jboss-classloading.xml"/>
<copy file="${ext.dir}/jboss/jboss-classloading.xml" tofile="${war.target.dir}/WEB-INF/jboss-classloading.xml" overwrite="true" />
-->
<cfmlengcrypt engine="railo" plaintext="${cfadmin.password}" property="railo.password.encrypted" />
<xmltask source="${railo.server.config.file}" dest="${railo.server.config.file}">
<attr path="/*[1]" attr="password" value="${railo.password.encrypted}" />
<attr path="/*[1]" attr="default-password" value="${railo.password.encrypted}" />
</xmltask>
<xmltask source="${railo.web.config.file}" dest="${railo.web.config.file}">
<attr path="/*[1]" attr="password" value="${railo.password.encrypted}" />
</xmltask>
<xmltask source="${railo.web.config.file}" dest="${railo.web.config.file}">
<insert path="//*[1]" position="under" xml="<charset/>" />
<attr path="/*[1]/charset" attr="resource-charset" value="${railo.charset.resource}" />
<attr path="/*[1]/charset" attr="template-charset" value="${railo.charset.template}" />
<attr path="/*[1]/charset" attr="web-charset" value="${railo.charset.web}" />
</xmltask>
<railo-scope setting="session-type" value="${cfml.session.type}" configfile="${railo.server.config.file}" />
<railo-scope setting="session-type" value="${cfml.session.type}"/>
<property name="railo.function.dir" value="" />
<antcontrib:if>
<not><equals arg1="${railo.function.dir}" arg2="" /></not>
<then>
<xmltask source="${railo.web.config.file}" dest="${railo.web.config.file}">
<attr path="/*[1]/file-system" attr="function-directory" value="${railo.function.dir}" />
</xmltask>
</then>
</antcontrib:if>
<antcontrib:runtarget target="railo.ra.install" />
</target>
<target name="railo.build">
<antcontrib:runtarget target="war.init" />
</target>
<target name="railo.build.binary">
<antcontrib:runtarget target="railo.build" />
<antcontrib:runtarget target="railo.compile-cf" />
</target>
<target name="railo.add.libs" if="add.libs.dir" unless="dont.add.libs">
<echo message="Copying libs: ${add.libs.dir} to: ${war.target.dir}/WEB-INF/lib/railo-server/context/lib" />
<addlibs from="${add.libs.dir}"/>
<!--
<copy todir="${war.target.dir}/WEB-INF/lib/railo-server/context/lib" overwrite="true">
<fileset dir="${add.libs.dir}"/>
</copy>
-->
</target>
<target name="railo.build.war.ra" depends="exists.archives.xml,railo.archives.build" if="exists.archives.xml">
<antcontrib:runtarget target="war.init" />
<antcontrib:for param="file">
<path>
<fileset dir="${railo.archive.dir}">
<include name="*.ra" />
</fileset>
</path>
<sequential>
<antcontrib:propertyregex override="yes" property="mappingName" input="@{file}" regexp=".*/([^\.]+).ra|.*\\([^\.]+).ra" replace="\1" />
<echo message="Adding mapping for archive - /${mappingName} - @{file}" />
<copy file="@{file}" todir="${war.target.dir}" overwrite="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<insert path="/*[1]/mappings" position="under">
<![CDATA[
<mapping
readonly="yes"
toplevel="true"
trusted="false"
virtual="/${mappingName}"
archive="{web-root-directory}/${mappingName}.ra"
primary="archive"
/>
]]>
</insert>
</xmltask>
</sequential>
</antcontrib:for>
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<attr path="/*[1]/java" attr="inspect-template" value="never" />
</xmltask>
</target>
<target name="railo.ra.install">
<antcontrib:for param="file">
<path>
<fileset dir="${basedir}/ra" erroronmissingdir="false">
<include name="*.ra" />
</fileset>
</path>
<sequential>
<antcontrib:propertyregex override="yes" property="mappingName" input="@{file}" regexp=".*/([^\.]+).ra|.*\\([^\.]+).ra" replace="\1" />
<echo message="Adding mapping for archive - /${mappingName} - @{file}" />
<copy file="@{file}" todir="${war.target.dir}" overwrite="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<insert path="/*[1]/mappings" position="under">
<![CDATA[
<mapping
readonly="yes"
toplevel="true"
trusted="false"
virtual="/${mappingName}"
archive="{web-root-directory}/${mappingName}.ra"
primary="archive"
/>
]]>
</insert>
</xmltask>
</sequential>
</antcontrib:for>
</target>
<target name="src.to.railo.archives.xml">
<echo file="${basedir}/railo.archives.${build.type}.xml" message="<archives></archives>" />
<abspath path="${railo.archive.dir}" property="railo.archive.dir" />
<antcontrib:for param="file">
<path>
<dirset dir="${src.dir}">
<include name="*" />
</dirset>
</path>
<sequential>
<antcontrib:propertyregex override="yes" property="mappingName" input="@{file}" regexp=".*/|.*\\([^\.]*)" replace="\1" />
<echo message="archive - ${mappingName} - @{file} ${railo.archive.dir}/${mappingName}.ra" />
<xmltask source="${basedir}/railo.archives.${build.type}.xml" dest="${basedir}/railo.archives.${build.type}.xml">
<insert path="archives" position="under">
<![CDATA[
<archive
archive="${railo.archive.dir}/${mappingName}.ra"
mapping="/${mappingName}"
physical="@{file}"
/>
]]>
</insert>
</xmltask>
</sequential>
</antcontrib:for>
</target>
<target name="exists.archives.xml">
<available file="${basedir}/archives.xml" type="file" property="exists.archives.xml" />
<antcontrib:if>
<equals arg1="${exists.archives.xml}" arg2="true" />
<then>
<echo message="Archives file exists : ${basedir}/archives.xml " />
</then>
<else>
<echo message="No archives.xml file to import : ${basedir}/archives.xml does not exist. Run the 'src.to.railo.archives.xml' task to generate one from everything in ${src.dir}" />
</else>
</antcontrib:if>
</target>
<target name="railo.mappings.xml.build" depends="exists.mappings.xml" if="exists.mappings.xml">
<xmltask sourcebuffer="mappings.buff">
<call path="mappings/*">
<param name="virtual" path="@virtual" default="NONE" />
<param name="physical" path="@physical" default="NONE" />
<param name="trusted" path="@trusted" default="false" />
<param name="readonly" path="@readonly" default="true" />
<actions>
<railo-mapping physical="@{physical}" virtual="@{virtual}" readonly="@{readonly}" trusted="@{trusted}" />
</actions>
</call>
</xmltask>
</target>
<target name="railo.customtags.xml.build" depends="exists.customtags.xml" if="exists.customtags.xml">
<xmltask sourcebuffer="customtags.buff">
<call path="mappings/*">
<param name="virtual" path="@virtual" default="NONE" />
<param name="physical" path="@physical" default="NONE" />
<actions>
<railo-customtag physical="@{physical}" virtual="@{virtual}" />
</actions>
</call>
</xmltask>
</target>
<target name="railo.mail.xml.build" depends="exists.mail.xml" if="exists.mail.xml">
<xmltask sourcebuffer="mail.buff" outputter="simple">
<call path="mail/settings">
<param name="log" path="@log" default="./temp/logs/mail.log" />
<param name="spool-enable" path="@spool-enable" default="yes" />
<param name="spool-interval" path="@spool-interval" default="5" />
<param name="timeout" path="@timeout" default="30" />
<actions>
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<attr path="/*[1]/mail" attr="log" value="@{log}" />
<attr path="/*[1]/mail" attr="spool-enable" value="@{spool-enable}" />
<attr path="/*[1]/mail" attr="spool-interval" value="@{spool-interval}" />
<attr path="/*[1]/mail" attr="timeout" value="@{timeout}" />
</xmltask>
</actions>
</call>
</xmltask>
<xmltask sourcebuffer="mail.buff">
<call path="mail/servers/*">
<param name="smtp" path="@smtp" default="smtp.gmail.com" />
<param name="port" path="@port" default="587" />
<param name="username" path="@username" default="" />
<param name="password" path="@password" default="" />
<param name="ssl" path="@ssl" default="false" />
<param name="tls" path="@tls" default="true" />
<actions>
<antcontrib:var name="mailserver.exists" unset="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<copy path="/*[1]/mail/server[@smtp='@{smtp}']/@smtp" attrValue="true" property="mailserver.exists" />
<replace path="/*[1]/mail/server[@smtp=@{smtp}]/text()" if="mailserver.exists">
<![CDATA[
<server
smtp="@{smtp}"
port="@{port}"
username="@{username}"
password="@{password}"
ssl="@{ssl}"
tls="@{tls}"
/>
]]>
</replace>
<insert path="/*[1]/mail" position="under" unless="mailserver.exists">
<![CDATA[
<server
smtp="@{smtp}"
port="@{port}"
username="@{username}"
password="@{password}"
ssl="@{ssl}"
tls="@{tls}"
/>
]]>
</insert>
</xmltask>
<antcontrib:switch value="${mailserver.exists}">
<case value="@{smtp}">
<echo message="Updated mail server - @{smtp} @{username}" />
</case>
<default>
<echo message="Added mail server - @{smtp} @{username}" />
</default>
</antcontrib:switch>
</actions>
</call>
</xmltask>
</target>
<target name="railo.datasources.build" depends="exists.datasources.xml" if="exists.datasources.xml">
<xmltask sourcebuffer="datasources.buff">
<call path="datasources/*">
<param name="name" path="@name" default="datasource" />
<param name="blob" path="@blob" default="false" />
<param name="clob" path="@clob" default="false" />
<param name="class" path="@class" default="org.gjt.mm.mysql.Driver" />
<param name="host" path="@host" default="localhost" />
<param name="port" path="@port" default="3306" />
<param name="database" path="@database" default="database" />
<param name="username" path="@username" default="sa" />
<param name="password" path="@password" default="" />
<param name="sqlstoredprocedures" path="@sqlstoredprocedures" default="true" />
<param name="sqlinsert" path="@sqlinsert" default="true" />
<param name="sqlselect" path="@sqlselect" default="true" />
<param name="sqlupdate" path="@sqlupdate" default="true" />
<param name="sqldelete" path="@sqldelete" default="true" />
<param name="maintainconnection" path="@maintainconnection" default="true" />
<param name="logintimeout" path="@logintimeout" default="120" />
<param name="connectionretries" path="@connectionretries" default="0" />
<param name="connectionlimit" path="@connectionlimit" default="-1" />
<param name="connectiontimeout" path="@connectiontimeout" default="120" />
<param name="storage" path="@storage" default="false" />
<param name="custom" path="@custom" default="" />
<param name="jdbc" path="@jdbc" default="mysql" />
<param name="jdbcstring" path="@jdbcstring" default="jdbc:mysql://{host}:{port}/{database}" />
<actions>
<antcontrib:var name="datasource.exists" unset="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<copy path="/*[1]/data-sources/data-source[@name='@{name}']/@name" attrValue="true" property="datasource.exists" />
<replace path="/*[1]/data-sources/data-source[@name='@{name}']" if="datasource.exists">
<![CDATA[
<data-source allow="415" blob="@{blob}"
name="@{name}"
class="@{class}"
host="@{host}" port="@{port}"
database="@{database}"
password="@{password}"
username="@{username}"
clob="@{clob}" connectionLimit="@{connectionlimit}" connectionTimeout="@{connectiontimeout}"
custom="@{custom}"
storage="@{storage}"
dsn="@{jdbcstring}"
/>
]]>
</replace>
<insert path="/*[1]/data-sources" position="under" unless="datasource.exists">
<![CDATA[
<data-source allow="415" blob="@{blob}"
name="@{name}"
class="@{class}"
host="@{host}" port="@{port}"
database="@{database}"
password="@{password}"
username="@{username}"
clob="@{clob}" connectionLimit="@{connectionlimit}" connectionTimeout="@{connectiontimeout}"
custom="@{custom}"
storage="@{storage}"
dsn="@{jdbcstring}"
/>
]]>
</insert>
</xmltask>
<antcontrib:switch value="${datasource.exists}">
<case value="@{name}">
<echo message="Updated Datasource - @{name}" />
</case>
<default>
<echo message="Added Datasource - @{name}" />
</default>
</antcontrib:switch>
</actions>
</call>
</xmltask>
<echo message="configured datasources" />
</target>
<target name="railo.scheduledtasks.build" depends="exists.scheduledtasks.xml" if="exists.scheduledtasks.xml">
<mkdir dir="${war.target.dir}/WEB-INF/railo/scheduler"/>
<xmltask sourcebuffer="scheduledtasks.buff" dest="${war.target.dir}/WEB-INF/railo/scheduler/scheduler.xml" outputter="simple" />
</target>
<target name="railo.compile-cf">
<antcontrib:runtarget target="railo.mappings.xml.build" />
<property name="build.cfc.url" value="http://${server.host}:${server.port.http}${war.contextpath}/_cfd_compile_temp/Build.cfc" />
<property name="compile.results.file" location="compile-results.txt" />
<mkdir dir="${war.target.dir}/_cfd_compile_temp" />
<railo-mapping virtual="/_cfd_compile_temp" physical="${war.target.dir}/_cfd_compile_temp" />
<copy file="${cfdistro.basedir}/Build.cfc" todir="${war.target.dir}/_cfd_compile_temp" />
<sequential>
<antcontrib:runtarget target="runwar.start" />
<echo file="${compile.results.file}" message="Compile results (${todays.date}): ${line.separator}${line.separator}"/>
<xmltask sourcebuffer="mappings.buff">
<call path="mappings/*">
<param name="virtual" path="@virtual" default="NONE" />
<param name="physical" path="@physical" default="NONE" />
<actions>
<sequential>
<echo message="@{virtual} @{physical}/"/>
<copy todir="${war.target.dir}@{virtual}" verbose="${cfdistro.debug}">
<fileset dir="@{physical}" />
</copy>
<echo message="Compiling mapping - @{virtual} - @{physical}" />
<get src="${build.cfc.url}?method=compile-mapping&mapping=@{virtual}&cfadminpassword=${cfadmin.password}"
dest="compile.results.temp" retries="1" verbose="true" ignoreerrors="true" />
<antcontrib:var name="compile.results" unset="true" />
<loadfile srcFile="compile.results.temp" property="compile.results" failonerror="false"/>
<property name="compile.results" value="<a href="${build.cfc.url}?method=compile-mapping&mapping=@{virtual}&cfadminpassword=${cfadmin.password}">Compile /@{virtual}</a>" />
<echo file="${compile.results.file}" append="true" message="${line.separator}${line.separator}*** mapping @{virtual} compile results: ${compile.results}"/>
<delete file="compile.results.temp"/>
<antcontrib:propertyregex override="yes" property="mappingName" input="@{virtual}" regexp=".*/|.*\\([^\.]*)" replace="\1" />
<copy todir="${war.target.dir}" verbose="${cfdistro.debug}" overwrite="true">
<fileset dir="${war.target.dir}/WEB-INF/railo/cfclasses/" />
<chainedmapper>
<regexpmapper from="^CF_.+_(${mappingName})\d{4}/+(.*)" to="\1/\2" />
<regexpmapper from="(.*)_cf(.).+\.class$$" to="\1.cf\2" />
</chainedmapper>
</copy>
</sequential>
</actions>
</call>
</xmltask>
<open-url url="${build.cfc.url}?method=show-results&resultsfile=${compile.results.file}" />
<sleep seconds="3" />
<!-- remove the mappings now that they're compiled -->
<xmltask sourcebuffer="mappings.buff">
<call path="mappings/*">
<param name="virtual" path="@virtual" default="NONE" />
<param name="physical" path="@physical" default="NONE" />
<actions>
<railo-mapping-remove virtual="@{virtual}" />
</actions>
</call>
</xmltask>
<antcontrib:runtarget target="runwar.stop" />
<delete file="${war.target.dir}/Build.cfc" />
<delete dir="${war.target.dir}/_cfd_compile_temp"/>
<railo-mapping-remove virtual="/_cfd_compile_temp" />
</sequential>
</target>
<target name="railo.archives.build" depends="exists.archives.xml" if="exists.archives.xml">
<copy todir="${runwar.war.path}">
<fileset dir="${cfdistro.basedir}" includes="Build.cfc"/>
<filterchain>
<expandproperties />
</filterchain>
</copy>
<copy file="${cfdistro.basedir}/cfadminpassword.txt" todir="${runwar.war.path}" />
<delete dir="${railo.archive.dir}" />
<antcontrib:var name="runwar.stop.socket" value="10923" />
<antcontrib:var name="runwar.port" value="10921" />
<sequential>
<antcontrib:runtarget target="runwar.start" />
<xmltask source="railo.archives.${build.type}.xml">
<call path="archives/*">
<param name="archive" path="@archive" default="NONE" />
<param name="physical" path="@physical" default="NONE" />
<param name="mapping" path="@mapping" default="NONE" />
<actions>
<echo message="Creating Railo Archive - @{archive} - @{physical} @ @{mapping}" />
<get src="http://127.0.0.1:${runwar.port}${runwar.war.contextpath}Build.cfc?method=compile-archive&mapping=@{mapping}&toFile=@{archive}" dest="${railo.archive.dir}/@{mapping}.archive.results.properties" verbose="true" ignoreerrors="true" />
</actions>
</call>
</xmltask>
<antcontrib:runtarget target="runwar.stop" />
</sequential>
<echo message="created archives from ${basedir}/railo.archives.${build.type}.xml" />
<delete file="${runwar.war.path}/Build.cfc" />
<delete file="${runwar.war.path}/cfadminpassword.txt" />
</target>
<target name="copy-to-bin">
<delete dir="${temp.dir}/bin" />
<mkdir dir="${temp.dir}/bin" />
<copy todir="${temp.dir}/bin" verbose="true">
<fileset dir="${basedir}/WEB-INF/railo/cfclasses/" />
<chainedmapper>
<regexpmapper from="^CF_.+_(.+)\d{4}/+(.*)" to="\1/\2" />
<regexpmapper from="(.*)_cf(.).+\.class$$" to="\1.cf\2" />
</chainedmapper>
</copy>
</target>
<target name="railo.set.log.dir">
<!-- <mkdir dir="${log.dir}" /> -->
<relpath property="log.dir" to="${log.dir}" from="${war.target.dir}/WEB-INF/railo/logs"/>
<echo message="setting logging dir to ${log.dir}"/>
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<attr path="/*[1]/remote-clients" attr="log" value="${log.dir}" />
<attr path="/*[1]/remote-clients" attr="log-level" value="info" />
<attr path="/*[1]/scope" attr="requesttimeout-log" value="${log.dir}requesttimeout.log" />
<attr path="/*[1]/scope" attr="requesttimeout" value="${cfml.request.timeout}" />
<attr path="/*[1]/scope" attr="applicationtimeout" value="${cfml.application.timeout}" />
<attr path="/*[1]/mail" attr="log" value="${log.dir}mail.log" />
<attr path="/*[1]/debugging" attr="memory-log" value="${log.dir}memory.log" />
<attr path="/*[1]/debugging" attr="debug" value="no" />
<attr path="/*[1]/application" attr="application-log" value="${log.dir}application.log" />
<attr path="/*[1]/application" attr="application-log-level" value="${log.level}" />
<attr path="/*[1]/application" attr="trace-log" value="${log.dir}trace.log" />
<attr path="/*[1]/application" attr="trace-log-level" value="${log.level}" />
<attr path="/*[1]/application" attr="exception-log" value="${log.dir}exception.log" />
</xmltask>
</target>
<target name="railo.set.debug">
<echo message="setting logging dir to ${log.dir}"/>
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<attr path="/*[1]/debugging" attr="debug" value="${debugging.enabled}" />
</xmltask>
</target>
<target name="railo.set.inspect.templates">
<echo message="Will inspect each template ${cfmlengine.inspect.templates}"/>
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<attr path="/*[1]/java" attr="inspect-template" value="${cfmlengine.inspect.templates}" />
</xmltask>
</target>
<target name="railo.set.security">
<echo message="Setting security options"/>
<antcontrib:var name="datasource.exists" unset="true" />
<xmltask source="${railo.server.config.file}" dest="${railo.server.config.file}">
<copy path="/*[1]/security" attrValue="true" property="security.exists" />
<replace path="/*[1]/security']" if="security.exists">
<![CDATA[
<security access_read="${railo.security.access_read}" access_write="${railo.security.access_write}"
cache="${railo.security.cache}" cfx_setting="${railo.security.cfx_setting}" cfx_usage="${railo.security.cfx_usage}"
custom_tag="${railo.security.custom_tag}" datasource="${railo.security.datasource}" debugging="${railo.security.debugging}"
direct_java_access="${railo.security.direct_java_access}" file="yes" gateway="yes" mail="yes" mapping="yes"
remote="yes" scheduled_task="yes" search="yes" setting="yes"
tag_execute="yes" tag_import="yes" tag_object="yes" tag_registry="yes"/>
]]>
</replace>
<insert path="/*[1]" position="under" unless="security.exists">
<![CDATA[
<security access_read="${railo.security.access_read}" access_write="${railo.security.access_write}"
cache="${railo.security.cache}" cfx_setting="${railo.security.cfx_setting}" cfx_usage="${railo.security.cfx_usage}"
custom_tag="${railo.security.custom_tag}" datasource="${railo.security.datasource}" debugging="${railo.security.debugging}"
direct_java_access="${railo.security.direct_java_access}" file="yes" gateway="yes" mail="yes" mapping="yes"
remote="yes" scheduled_task="yes" search="yes" setting="yes"
tag_execute="yes" tag_import="yes" tag_object="yes" tag_registry="yes"/>
]]>
</insert>
</xmltask>
</target>
<target name="railo.add.build.cfc">
<mkdir dir="${war.target.dir}/_cfd_compile_temp" />
<railo-mapping virtual="/_cfd_compile_temp" physical="${war.target.dir}/_cfd_compile_temp" />
<copy file="${cfdistro.basedir}/Build.cfc" todir="${war.target.dir}/_cfd_compile_temp" />
</target>
<macrodef name="railo-mapping">
<attribute name="physical" />
<attribute name="virtual" />
<attribute name="archive" default=""/>
<attribute name="readonly" default="true"/>
<attribute name="trusted" default="false"/>
<sequential>
<antcontrib:var name="___physical" value="@{physical}" />
<antcontrib:if>
<equals arg1="${copy.mappings.to.war}" arg2="true" />
<then>
<echo message="copying @{physical} to ${war.target.dir}/@{virtual}" />
<copy todir="${war.target.dir}/@{virtual}" verbose="false">
<fileset dir="@{physical}"/>
</copy>
</then>
<else>
<antcontrib:if>
<equals arg1="${mappings.relative}" arg2="true" />
<then>
<antcontrib:var name="___physical" unset="true" />
<relpath from="${war.target.dir}" to="@{physical}" property="___physical"/>
</then>
</antcontrib:if>
<antcontrib:var name="mapping.exists" unset="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<copy path="/*[1]/mappings/mapping[@virtual='@{virtual}']/@virtual" attrValue="true" property="mapping.exists" />
<replace path="/*[1]/mappings/mapping[@virtual='@{virtual}']" if="mapping.exists">
<![CDATA[
<mapping
readonly="@{readonly}"
trusted="@{trusted}"
virtual="@{virtual}"
physical="${___physical}"
archive="@{archive}"
primary="physical"
/>
]]>
</replace>
<insert path="/*[1]/mappings" position="under" unless="mapping.exists">
<![CDATA[
<mapping
readonly="@{readonly}"
trusted="@{trusted}"
virtual="@{virtual}"
physical="${___physical}"
archive="@{archive}"
primary="physical"
/>
]]>
</insert>
</xmltask>
<antcontrib:switch value="${mapping.exists}">
<case value="@{virtual}">
<echo message="Updated Mapping - @{virtual} ${___physical}" />
</case>
<default>
<echo message="Added Mapping - @{virtual} ${___physical}" />
</default>
</antcontrib:switch>
</else>
</antcontrib:if>
<antcontrib:var name="___physical" unset="true" />
</sequential>
</macrodef>
<macrodef name="railo-rest-mapping">
<attribute name="physical" />
<attribute name="virtual" />
<attribute name="servletMapping" default="@{virtual}/*"/>
<attribute name="default" default="true"/>
<sequential>
<servlet-mapping rest="true" virtual="@{servletMapping}" physical="@{physical}" />
<antcontrib:var name="___physical" value="@{physical}" />
<antcontrib:if>
<equals arg1="${mappings.relative}" arg2="true" />
<then>
<antcontrib:var name="___physical" unset="true" />
<relpath from="${war.target.dir}" to="@{physical}" property="___physical"/>
</then>
</antcontrib:if>
<antcontrib:var name="mapping.exists" unset="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<copy path="/*[1]/rest/mapping/@virtual" attrValue="true" property="mapping.exists" />
<insert path="/*[1]" position="under" unless="mapping.exists">
<![CDATA[<rest></rest>]]>
</insert>
</xmltask>
<antcontrib:var name="mapping.exists" unset="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<copy path="/*[1]/rest/mapping[@virtual='@{virtual}']/@virtual" attrValue="true" property="mapping.exists" />
<replace path="/*[1]/rest/mapping[@virtual='@{virtual}']" if="mapping.exists">
<![CDATA[
<mapping
virtual="@{virtual}"
physical="${___physical}"
default="@{default}"
/>
]]>
</replace>
<insert path="/*[1]/rest" position="under" unless="mapping.exists">
<![CDATA[
<mapping
virtual="@{virtual}"
physical="${___physical}"
default="@{default}"
/>
]]>
</insert>
</xmltask>
<antcontrib:switch value="${mapping.exists}">
<case value="@{virtual}">
<echo message="Updated REST Mapping - @{virtual} ${___physical}" />
</case>
<default>
<echo message="Added REST Mapping - @{virtual} ${___physical}" />
</default>
</antcontrib:switch>
<antcontrib:var name="___physical" unset="true" />
</sequential>
</macrodef>
<macrodef name="railo-customtag">
<attribute name="physical" />
<attribute name="virtual" />
<attribute name="contextType" default="web" />
<sequential>
<antcontrib:if>
<equals arg1="@{contextType}" arg2="web" />
<then>
<antcontrib:var name="railo.customtags.dir" value="${railo.web.customtags.dir}"/>
</then>
<else>
<antcontrib:var name="railo.customtags.dir" value="${railo.server.customtags.dir}"/>
</else>
</antcontrib:if>
<relpath property="customtag.physical" from="${war.target.dir}" to="@{physical}" />
<antcontrib:if>
<equals arg1="${copy.mappings.to.war}" arg2="true" />
<then>
<echo message="Copying Custom Tag @{physical} to ${railo.customtags.dir}@{virtual}" />
<copy todir="${railo.customtags.dir}@{virtual}">
<fileset dir="@{physical}"/>
</copy>
<antcontrib:var name="customtag.physical" unset="true"/>
<relpath property="customtag.physical" from="${war.target.dir}" to="${railo.customtags.dir}@{virtual}" />
</then>
</antcontrib:if>
<antcontrib:var name="mapping.exists" unset="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<copy path="/*[1]/custom-tag/mapping[@physical='${customtag.physical}']/@physical" attrValue="true" property="mapping.exists" />
<replace path="/*[1]/custom-tag/mapping[@physical='${customtag.physical}']/text()" if="mapping.exists">
<![CDATA[
<mapping
trusted="false"
physical="${customtag.physical}"
/>
]]>
</replace>
<insert path="/*[1]/custom-tag" position="under" unless="mapping.exists">
<![CDATA[
<mapping
trusted="false"
physical="${customtag.physical}"
/>
]]>
</insert>
</xmltask>
<antcontrib:switch value="${mapping.exists}">
<case value="${customtag.physical}">
<echo message="Updated Custom Tag Mapping - ${customtag.physical}" />
</case>
<default>
<echo message="Added Custom Tag Mapping - ${customtag.physical}" />
</default>
</antcontrib:switch>
</sequential>
</macrodef>
<macrodef name="railo-datasource">
<attribute name="name"/>
<attribute name="blob" default="false" />
<attribute name="clob" default="false" />
<attribute name="class" default="org.h2.Driver" />
<attribute name="host" default="127.0.0.1" />
<attribute name="port" default="3306" />
<attribute name="database" default="railo-db" />
<attribute name="username" default="sa" />
<attribute name="password" default="" />
<attribute name="sqlstoredprocedures" default="true" />
<attribute name="sqlinsert" default="true" />
<attribute name="sqlselect" default="true" />
<attribute name="sqlupdate" default="true" />
<attribute name="sqldelete" default="true" />
<attribute name="maintainconnection" default="true" />
<attribute name="logintimeout" default="120" />
<attribute name="connectionretries" default="0" />
<attribute name="connectionlimit" default="-1" />
<attribute name="connectiontimeout" default="120" />
<attribute name="custom" default="" />
<attribute name="jdbc" default="h2" />
<attribute name="jdbcstring" default="jdbc:h2:./h2dbs/railo-db/railo-db" />
<sequential>
<antcontrib:var name="datasource.exists" unset="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<copy path="/*[1]/data-sources/data-source[@name='@{name}']/@name" attrValue="true" property="datasource.exists" />
<replace path="/*[1]/data-sources/data-source[@name='@{name}']" if="datasource.exists">
<![CDATA[
<data-source allow="415" blob="@{blob}"
name="@{name}"
class="@{class}"
host="@{host}" port="@{port}"
database="@{database}"
password="@{password}"
username="@{username}"
clob="@{clob}" connectionLimit="@{connectionlimit}" connectionTimeout="@{connectiontimeout}"
custom="@{custom}"
dsn="@{jdbcstring}"
/>
]]>
</replace>
<insert path="/*[1]/data-sources" position="under" unless="datasource.exists">
<![CDATA[
<data-source allow="415" blob="@{blob}"
name="@{name}"
class="@{class}"
host="@{host}" port="@{port}"
database="@{database}"
password="@{password}"
username="@{username}"
clob="@{clob}" connectionLimit="@{connectionlimit}" connectionTimeout="@{connectiontimeout}"
custom="@{custom}"
dsn="@{jdbcstring}"
/>
]]>
</insert>
</xmltask>
<antcontrib:switch value="${datasource.exists}">
<case value="@{name}">
<echo message="Updated Datasource - @{name}" />
</case>
<default>
<echo message="Added Datasource - @{name}" />
</default>
</antcontrib:switch>
</sequential>
</macrodef>
<macrodef name="railo-cache">
<attribute name="name"/>
<attribute name="class"/>
<attribute name="custom"/>
<attribute name="storage"/>
<attribute name="default-type" default=""/>
<attribute name="read-only" default="false"/>
<sequential>
<antcontrib:if>
<equals arg1="${default.cfengine}" arg2="railo" />
<then>
<antcontrib:var name="some.cache.exists" unset="true" />
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<xmlcatalog refId="commonDTDs" />
<copy path="//*[1]/cache/text()" property="some.cache.exists" />
<!-- if no caches at all, just insert -->
<insert path="//*[1]" position="under" unless="some.cache.exists">
<![CDATA[<cache>
<connection class="@{class}" custom="@{custom}" name="@{name}" read-only="@{read-only}" storage="@{storage}"/></cache>]]>
</insert>
<copy path="//*[1]/cache/connection[@name='@{name}']/@name" attrValue="true" property="cache.exists" />
<replace path="//*[1]/cache/connection[@name='@{name}']" if="cache.exists">
<![CDATA[
<connection class="@{class}" custom="@{custom}" name="@{name}" read-only="@{read-only}" storage="@{storage}"/>
]]>
</replace>
<insert path="//*[1]/cache" position="under" unless="cache.exists">
<![CDATA[
<connection class="@{class}" custom="@{custom}" name="@{name}" read-only="@{read-only}" storage="@{storage}"/>
]]>
</insert>
</xmltask>
<antcontrib:if>
<equals arg1="@{default-type}" arg2="" />
<then/>
<else>
<xmltask source="${railo.config.file}" dest="${railo.config.file}">
<attr path="/*[1]/cache" attr="@{default-type}" value="@{name}" />
</xmltask>
</else>
</antcontrib:if>
<!-- if some caches exist we can update and add -->
<antcontrib:switch value="${cache.exists}">
<case value="true">
<echo message="updated @{default-type} cache provider @{name} (@{class})" />
</case>
<default>
<echo message="added @{default-type} cache provider @{name} (@{class})" />
</default>
</antcontrib:switch>
<antcontrib:var name="cache.exists" unset="true" />
</then>
<else>
<echo> *** cache providers are useless for ${default.cfengine} hombre!</echo>
</else>
</antcontrib:if>
</sequential>
</macrodef>
<target name="extension.loadprops">
<!-- these property files will override the defaults -->
<property file="${basedir}/build.properties" />
<property file="${basedir}/build.extension.properties" />
<filter filtersfile="${basedir}/build.properties" />
<!-- defaults -->
<property file="${cfdistro.basedir}/buildtypes/build.extension.properties" />
</target>
<target name="extension.build" description="builds the extension" depends="extension.loadprops">
<echo message="Building Extension" />
<tstamp/>
<delete dir="${extension.temp.dir}" />
<mkdir dir="${extension.temp.dir}" />
<mkdir dir="${extension.dist}" />
<propertyfile file="${basedir}/build.extension.lastbuild" comment="Extension Build Information">
<entry key="build.date" type="date" pattern="MM-dd-yyyy HH:mm:ss" value="now" />
<entry key="build.time" type="date" pattern="kk:mm:ss" value="now" />
<entry key="build.timestamp" type="date" pattern="MM-dd-yyyy' at 'HH:mm:ss" value="now" />
<entry key="build.lastcommithash" default="" />
</propertyfile>
<property file="${basedir}/build.extension.lastbuild" />
<property name="extension.version" value="0.0.0.1"/>
<property name="extension.version.bump" value="" description="one of [major|minor|build|revision] or empty to not bump number." />
<version-splitter property="extension.build.version" version="${extension.version}" bump="${extension.version.bump}"/>
<antcontrib:var name="extension.version" value="${extension.build.version.long}" />
<echoproperties>
<propertyset>
<propertyref prefix="build." />
<propertyref prefix="extension." />
</propertyset>
</echoproperties>
<antcontrib:var name="extension.majorminor" value="${extension.build.version.major}.${extension.build.version.minor}"/>
<antcontrib:var name="extension.archive" value="${extension.name}-${extension.majorminor}-extension.zip"/>
<delete file="${extension.dist}/${extension.archive}" />
<antcontrib:if>
<available file="${extension.src}/config.xml"/>
<then>
<copy overwrite="yes" verbose="no" file="${extension.src}/config.xml" tofile="${extension.temp.dir}/config.xml" filtering="true">
<filterchain><expandproperties /></filterchain>
</copy>
</then>
<else>
<copy overwrite="yes" verbose="no" file="${cfdistro.basedir}/extension/config.xml" tofile="${extension.temp.dir}/config.xml" filtering="true">
<filterchain><expandproperties /></filterchain>
</copy>
</else>
</antcontrib:if>
<antcontrib:if>
<and><available file="${extension.java.src.dir}"/><not><equals arg1="${extension.java.compile}" arg2="false" /></not></and>
<then>
<property name="extension.java.jar" value="${extension.name}-extension.jar" />
<echo message="Compiling and jaring Java sources to ${extension.lib}/${extension.java.jar}"/>
<path id="extension-java-jar-classpath">
<fileset dir="${extension.lib}" erroronmissingdir="false">
<include name="*.jar"/>
</fileset>
<fileset dir="${war.target.dir}/WEB-INF/lib/">
<include name="*.jar"/>
</fileset>
<fileset dir="${cfdistro.lib.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${extension.java.lib.dir}" erroronmissingdir="false">
<include name="*.jar"/>
</fileset>
</path>
<mkdir dir="${extension.java.bin.dir}" />
<javac-ecj srcdir="${extension.java.src.dir}" destdir="${extension.java.bin.dir}"
compliance="1.6" target="1.6" fork="false"
classpath="${toString:extension-java-jar-classpath}"/>
<jar basedir="${extension.java.bin.dir}" destfile="${extension.lib}/${extension.java.jar}" />
<delete dir="${extension.java.bin.dir}" />
</then>