-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.xml
1543 lines (1443 loc) · 76.2 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"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project name="OFBiz Main Build" default="build" basedir="."
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:sonar="antlib:org.sonar.ant:sonar">
<taskdef uri="antlib:org.apache.ivy.ant" resource="org/apache/ivy/ant/antlib.xml">
<classpath>
<pathelement location="framework/base/lib/ivy-2.2.0.jar"/>
</classpath>
</taskdef>
<import file="macros.xml"/>
<property name="site.dir" value="../site"/>
<property name="memory.initial.param" value="-Xms128M"/>
<property name="memory.max.param" value="-Xmx512M"/>
<import file="framework/build.xml" optional="false"/>
<!-- ================================================================== -->
<!-- Initialization of all property settings -->
<!-- ================================================================== -->
<target name="ofbiz-init" depends="dir-init">
<property environment="env"/>
</target>
<target name="dir-init">
<mkdir dir="runtime"/>
<mkdir dir="runtime/output"/>
<mkdir dir="runtime/logs"/>
<mkdir dir="runtime/logs/test-results"/>
<mkdir dir="runtime/data"/>
<mkdir dir="runtime/data/derby"/>
</target>
<target name="sonar-init">
<taskdef uri="antlib:org.sonar.ant:sonar" resource="org/sonar/ant/antlib.xml">
<classpath>
<pathelement location="framework/base/lib/sonar-ant-task-1.3.jar"/>
</classpath>
</taskdef>
</target>
<!-- ================================================================== -->
<!-- Removes all created files and directories -->
<!-- ================================================================== -->
<target name="refresh"
description="Clean all and rebuild">
<antcall target="clean-all"/>
<antcall target="build"/>
</target>
<target name="clean-all"
description="Clean all DB, Catalina and caches data, logs, and runtime subdirectories and all specific files like .rej, .orig">
<antcall target="clean-ivy"/>
<antcall target="clean-data"/>
<antcall target="clean-logs"/>
<antcall target="clean-output"/>
<antcall target="clean-xtra"/>
<antcall target="clean-catalina"/>
<antcall target="clean-cache"/>
<antcall target="clean-tempfiles"/>
<antcall target="clean-search-indexes"/>
<antcall target="clean-downloads"/>
<antcall target="clean-uploads"/>
<antcall target="clean"/>
</target>
<target name="clean-downloads"
description="Clean all downloaded files">
<delete verbose="true" deleteonexit="true">
<fileset dir="framework/base/lib" includes="cobertura-*.jar"/>
<fileset dir="framework/base/lib" includes="sonar-*.jar"/>
<fileset dir="framework/base/lib" includes="activemq-*.jar"/>
<fileset dir="framework/entity/lib/jdbc" includes="postgresql-*.jar"/>
<fileset dir="framework/entity/lib/jdbc" includes="mysql-*.jar"/>
</delete>
<antcall target="clean-ivy"/>
</target>
<target name="clean-data"
description="Clean all DB data (Derby) under runtime/data">
<delete verbose="on" includeemptydirs="true">
<fileset dir="runtime/data" includes="**/*">
<exclude name="README"/>
<exclude name="derby.properties"/>
</fileset>
</delete>
<delete file="runtime/data.zip"/>
<delete file="runtime/test-list-build.xml"/>
</target>
<target name="clean-logs"
description="Clean all logs in runtime/logs">
<delete verbose="on" includeemptydirs="true">
<fileset dir="runtime/logs" includes="**/*">
<exclude name="README"/>
</fileset>
</delete>
</target>
<target name="clean-output"
description="Clean runtime/output directory">
<delete verbose="on" includeemptydirs="true">
<fileset dir="runtime/output" includes="**/*">
<exclude name="README"/>
</fileset>
</delete>
</target>
<target name="clean-xtra"
description="Clean all other files like .rej, .orig, etc.">
<delete verbose="on">
<fileset dir="." includes="**/.nbattrs,**/*~,**/.#*,**/.DS_Store,**/*.rej,**/*.orig"/>
</delete>
</target>
<target name="clean-catalina"
description="Clean Catalina data in runtime/catalina/work">
<delete dir="runtime/catalina/work"/>
</target>
<target name="clean-cache"
description="Clean the UtilCache file if errors found with old objects in the cache (Java runtime error something like 'local class incompatible')">
<property file="framework/base/config/cache.properties"/>
<echo message="NOTICE: deleting ${cache.file.store}.db"/>
<delete file="${cache.file.store}.db" verbose="true"/>
</target>
<target name="clean-tempfiles"
description="Remove files located in runtime/tempfiles (captcha, etc...)">
<delete includeemptydirs="true">
<fileset dir="./runtime/tempfiles" includes="**/*">
<exclude name="README"/>
</fileset>
</delete>
</target>
<target name="clean-search-indexes"
description="Remove search indexes (e.g. Lucene indexes) created under runtime/indexes">
<delete includeemptydirs="true">
<fileset dir="./runtime/indexes" includes="**/*" erroronmissingdir="false">
<exclude name="README"/>
<exclude name="index.properties"/>
</fileset>
</delete>
</target>
<target name="clean-uploads"
description="Remove uploaded files">
<delete includeemptydirs="true">
<fileset dir="./runtime/uploads" includes="**/*" erroronmissingdir="false"/>
</delete>
</target>
<target name="tests" depends="ofbiz-init">
<iterate target="tests" filelist="test-builds"/>
</target>
<target name="clean">
<ivy:cleancache/>
<hotdeployant target="clean"/>
<antcall target="clean-framework"/>
<delete file="ofbiz.jar"/>
<echo message="[clean] ========== Done Cleaning =========="/>
</target>
<target name="clean-framework">
<iterate target="clean" filelist="framework-builds"/>
</target>
<target name="svninfo"
description="Update the Release-revision info in the footer. Note that you need a valid Internet connection and Subversion connected to the OFBiz repository for that ">
<echo message="Creating svninfo..."/>
<exec executable="svn" dir="." output="runtime/svninfo_tmp.xml">
<arg value="info"/>
<arg value="--xml"/>
</exec>
<xmlproperty file="runtime/svninfo_tmp.xml"/>
<echo message="Rev:${info.entry.commit(revision)}"/>
<basename property="releasePath" file="${info.entry.url}"/>
<tstamp>
<format property="dateTime" pattern="yyyy-MM-dd HH:mm:ss"/>
</tstamp>
<echo message=" - Release-revision : ${releasePath}-r${info.entry.commit(revision)}, ${uiLabelMap.CommonBuiltOn} ${dateTime} ${uiLabelMap.CommonWith} Java ${java.version}"
file="runtime/svninfo.ftl"/>
<delete file="runtime/svninfo_tmp.xml"/>
<echo message="Done!"/>
</target>
<target name="clean-svninfo">
<echo message="Resetting svninfo..."/>
<echo message=" " file="runtime/svninfo.ftl"/>
<echo message="Done!"/>
</target>
<target name="gitinfo"
description="Update the Git Branch-revision info in the footer.">
<echo message="Creating gitinfo..."/>
<exec executable="git" outputproperty="branch">
<arg value="rev-parse"/>
<arg value="--abbrev-ref"/>
<arg value="HEAD"/>
</exec>
<exec executable="git" outputproperty="revision">
<arg value="rev-parse"/>
<arg value="HEAD"/>
</exec>
<tstamp>
<format property="dateTime" pattern="yyyy-MM-dd HH:mm:ss"/>
</tstamp>
<echo message="Found Branch-revision: ${branch}-${revision}"/>
<echo message=" - Branch-revision: ${branch}-${revision}, ${uiLabelMap.CommonBuiltOn} ${dateTime} ${uiLabelMap.CommonWith} Java ${java.version}"
file="runtime/gitinfo.ftl"/>
<echo message="Done!"/>
</target>
<target name="clean-gitinfo">
<echo message="Resetting gitinfo..."/>
<echo message=" " file="runtime/gitinfo.ftl"/>
<echo message="Done!"/>
</target>
<!-- ================================================================== -->
<!-- Apply patches where needed -->
<!-- ================================================================== -->
<target name="build-dev"
description="Patch sources in a dev environment if patch files are present in runtime/patches.">
<!-- Ant patch task can't handle a fileset => create a global patch -->
<concat destfile="${basedir}/runtime/patches/dev.patch" encoding="UTF-8" outputencoding="UTF-8">
<fileset dir="${basedir}/runtime/patches" casesensitive="no">
<exclude name="dev.patch"/> <!-- exclude the patch itself in case it's still there -->
<include name="*.patch"/>
</fileset>
</concat>
<if>
<available file="${basedir}/runtime/patches/dev.patch"/>
<then>
<antcall target="patch">
<param name="dir-name" value="${basedir}"/>
<param name="diff-file" value="${basedir}/runtime/patches/dev.patch"/>
</antcall>
<delete file="${basedir}/runtime/patches/dev.patch"/>
</then>
</if>
</target>
<!-- Following allow to use "svn patch" and fallback on "patch" if necessary -->
<target name="calculate-svn-patch-available">
<mkdir dir="build/svn-check"/>
<exec dir="build/svn-check" output="build/svn-check/svn.output" executable="svn" failonerror="true">
<arg value="--version"/>
</exec>
<loadfile property="svn-output" srcFile="build/svn-check/svn.output"/>
<condition property="svn-version-ok">
<!-- On Linux prefer patch because "svn patch" needs "ant exec and you can't check patching errors -->
<and>
<os family="windows"/>
<or>
<!-- This might also depend on the format of the working copy -->
<contains string="${svn-output}" substring="1.7."/>
<contains string="${svn-output}" substring="1.8."/>
<contains string="${svn-output}" substring="1.9."/>
<contains string="${svn-output}" substring="1.10."/>
<contains string="${svn-output}" substring="1.11."/>
</or>
</and>
</condition>
<delete dir="build/svn-check"/>
</target>
<target name="calculate-patch-available" depends="calculate-svn-patch-available" unless="svn-version-ok">
<condition property="patch-ok">
<os family="unix"/>
</condition>
</target>
<target name="check-svn-patch-available" depends="calculate-svn-patch-available" unless="svn-version-ok">
<echo message="You need svn version 1.7 or higher - attempting patch instead."/>
</target>
<target name="check-patch-available" depends="calculate-patch-available" unless="patch-ok"/>
<target name="patch-via-svn" depends="check-svn-patch-available" if="svn-version-ok">
<exec dir="${basedir}" executable="svn" failonerror="true">
<arg value="patch"/>
<arg value="${diff-file}"/>
<arg value="${dir-name}"/>
</exec>
</target>
<target name="patch-via-patch" depends="check-patch-available" if="patch-ok">
<exec dir="${basedir}" executable="patch" input="${diff-file}" failonerror="true">
<arg value="--binary"/><!-- To prevent EOL issues which comes when using mixed development platforms (ie Unix and Win) -->
<arg value="-p0"/>
</exec>
</target>
<target name="patch" depends="patch-via-svn,patch-via-patch"/>
<target name="revert-dev"
description="Revert patch files present in runtime/patches applied by build-dev.">
<!-- Ant patch task can't handle a fileset => create a global patch -->
<concat destfile="${basedir}/runtime/patches/dev.patch" encoding="UTF-8" outputencoding="UTF-8">
<fileset dir="${basedir}/runtime/patches" casesensitive="no">
<exclude name="dev.patch"/> <!-- exclude the patch itself in case it's still there -->
<include name="*.patch"/>
</fileset>
</concat>
<if>
<available file="${basedir}/runtime/patches/dev.patch"/>
<then>
<antcall target="revert-patch">
<param name="dir-name" value="${basedir}"/>
<param name="diff-file" value="${basedir}/runtime/patches/dev.patch"/>
</antcall>
<delete file="${basedir}/runtime/patches/dev.patch"/>
</then>
</if>
</target>
<target name="revert-via-svn" depends="check-svn-patch-available" if="svn-version-ok">
<exec dir="${basedir}" executable="svn" failonerror="true">
<arg value="patch"/>
<arg value="${diff-file}"/>
<arg value="${dir-name}"/>
<arg value="--reverse-diff"/>
</exec>
</target>
<target name="revert-via-patch" depends="check-patch-available" if="patch-ok">
<exec dir="${basedir}" executable="patch" input="${diff-file}" failonerror="true">
<arg value="--binary"/><!-- To prevent EOL issues which comes when using mixed development platforms (ie Unix and Win) -->
<arg value="-p0"/>
<arg value="-R"/>
</exec>
</target>
<target name="revert-patch" depends="revert-via-svn,revert-via-patch"/>
<target name="build-test"
description="Patch and build all sources for use in a test environment. On Windows you need to have patch.exe in the path and patch files must all be in dos format (CR+LF)">
<subant inheritall="false" target="prepare-to-build-test" failonerror="true">
<fileset dir="${basedir}/applications" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
</fileset>
</subant>
<!--antcall target="build"/--><!-- you can chain the main target (build in this file) if you don't use build-dev -->
</target>
<target name="build-qa"
description="Patch and build all sources for use in a qa environment. On Windows you need to have patch.exe in the path and patch files must all be in dos format (CR+LF)">
<subant inheritall="false" target="prepare-to-build-qa" failonerror="true">
<fileset dir="${basedir}/applications" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
</fileset>
</subant>
<!--antcall target="build"/--><!-- you can chain the main target (build in this file) if you don't use build-dev -->
</target>
<target name="build-production"
description="Patch and build all sources for use in a live environment. On Windows you need to have patch.exe in the path and patch files must all be in dos format (CR+LF)">
<subant inheritall="false" target="prepare-to-build-production" failonerror="true">
<fileset dir="${basedir}/applications" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
</fileset>
</subant>
<!--antcall target="build"/--><!-- you can chain the main target (build in this file) if you don't use build-dev -->
</target>
<!-- ================================================================== -->
<!-- Build Components -->
<!-- ================================================================== -->
<target name="build" depends="ofbiz-init">
<echo message="[build] ========== Start Building (Compile) =========="/>
<antcall target="build-dev"/>
<antcall target="build-framework"/>
<!-- <antcall target="build-applications"/>
<antcall target="build-specialpurpose"/> -->
<externalsubant>
<fileset dir="${basedir}/themes">
<include name="*/build.xml"/>
</fileset>
</externalsubant>
<hotdeployant/>
<antcall target="clean-svninfo"/>
<antcall target="clean-gitinfo"/>
<echo message="[build] ========== Done Building (Compile) =========="/>
</target>
<target name="build-framework">
<iterate target="jar" filelist="framework-builds"/>
</target>
<!-- <target name="build-applications" if="${applications.present}">
<iterate target="jar" filelist="application-builds"/>
</target>
<target name="build-specialpurpose" if="${specialpurpose.present}">
<iterate target="jar" filelist="specialpurpose-builds"/>
</target> -->
<macrodef name="hotdeployant">
<attribute name="target" default=""/>
<sequential>
<!-- a check is done, if no build.xml file is present in hot-deploy dir,
then the build.xml files - if present - in hot-deploy sub-dirs will be used.
So the previous, simpler, behaviour is kept as long as you don't need
to build hot-deploy components in a specific order. -->
<externalsubant target="@{target}">
<fileset dir="${basedir}/applications" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
</fileset>
</externalsubant>
</sequential>
</macrodef>
<!-- ================================================================== -->
<!-- Build JavaDocs -->
<!-- ================================================================== -->
<target name="docs-framework">
<iterate target="docs" filelist="framework-builds"/>
</target>
<target name="docs-all"
depends="build,ofbiz-init"><!--description="For committers : Build all javadoc into one tree for easier viewing by the community" Note: this is now done automatically by Buildbot at the ASF-->
<echo message="[docs-all] ========== Start Building (JavaDoc) =========="/>
<mkdir dir="${site.dir}/javadocs"/>
<path id="local.class.path">
<fileset dir="${ofbiz.home.dir}/framework/base/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/commons" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/j2eespecs" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/scripting" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/catalina/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/entity/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/geronimo/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/service/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/testtools/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/webapp/lib" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/webapp/build/lib" includes="*.jar"/>
</path>
<property name="desc" value="API"/>
<property name="build.dir" value="${site.dir}"/>
<default-javadoc/>
<echo message="[docs-all] ========== Done Building (JavaDocs) =========="/>
</target>
<!-- ================================================================== -->
<!-- Contrib Targets -->
<!-- ================================================================== -->
<target name="copy-contrib">
<copy todir="${basedir}" overwrite="true" verbose="true">
<fileset dir="${basedir}/contrib" excludes="contrib/**,**/*.class"/>
</copy>
</target>
<target name="build-contrib" depends="copy-contrib,refresh"/>
<!-- ================================================================== -->
<!-- WebSite Targets -->
<!-- ================================================================== -->
<target name="copy-apis">
<mkdir dir="${site.dir}/api"/>
<mkdir dir="${site.dir}/api/framework"/>
<!--<mkdir dir="${site.dir}/api/applications"/>
<mkdir dir="${site.dir}/api/specialpurpose"/> -->
<copy todir="${site.dir}/api/framework">
<fileset dir="${basedir}/framework" includes="*/build/javadocs/**"/>
</copy>
<!-- <copy todir="${site.dir}/api/applications">
<fileset dir="${basedir}/applications" includes="*/build/javadocs/**"/>
</copy>
<copy todir="${site.dir}/api/specialpurpose">
<fileset dir="${basedir}/specialpurpose" includes="*/build/javadocs/**"/>
</copy>-->
</target>
<target name="copy-dtds"
description="For committers : Copy all dtds from OFBiz instance to website">
<mkdir dir="${site.dir}/dtds"/>
<copy todir="${site.dir}/dtds" flatten="true" overwrite="true">
<fileset dir="${basedir}" includes="**/*.dtd"/>
<fileset dir="${basedir}" defaultexcludes="yes"> <!-- all but oagis and external in general -->
<include name="**/*.xsd"/>
<exclude name="**/002*.xsd"/>
<exclude name="**/068*.xsd"/>
<exclude name="**/161*.xsd"/>
<exclude name="**/196*.xsd"/>
<exclude name="**/197*.xsd"/>
</fileset>
</copy>
</target>
<!-- ================================================================== -->
<!-- Script Targets -->
<!-- ================================================================== -->
<target name="scriptfix">
<fixcrlf srcdir="${basedir}" eol="lf" eof="remove" includes="**/*.sh"/>
<fixcrlf srcdir="${basedir}" eol="crlf" includes="**/*.bat"/>
</target>
<!-- ================================================================== -->
<!-- Start and Stop OFBiz -->
<!-- ================================================================== -->
<target name="start"
description="Start OFBiz (use -Dportoffset=portNumber to shift all ports with the portNumber value)">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="start"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<target name="start-secure"
description="Same than start but pre-loading the notsoserial Java agent (from tools/security/notsoserial) to protect OFBiz from the Java deserialization vulnerability">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="-javaagent:${ofbiz.home.dir}/tools/security/notsoserial/notsoserial-1.0-SNAPSHOT.jar"/>
<jvmarg value="-Dnotsoserial.whitelist=${ofbiz.home.dir}/tools/security/notsoserial/empty.txt"/>
<jvmarg value="-Dnotsoserial.dryrun=${ofbiz.home.dir}/tools/security/notsoserial/is-deserialized.txt"/>
<jvmarg value="-Dnotsoserial.trace=${ofbiz.home.dir}/tools/security/notsoserial/deserialize-trace.txt"/>
<arg value="start"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<target name="start-batch"
description="Start OFBiz as a separate process. Use -Dportoffset=portNumber to shift all ports with the portNumber value.">
<java jar="ofbiz.jar" fork="true" spawn="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="start-batch"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<target name="start-batch-secure"
description="Same than start-batch but pre-loading the notsoserial Java agent (from tools/security/notsoserial) to protect OFBiz from the Java deserialization vulnerability">
<java jar="ofbiz.jar" fork="true" spawn="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="-javaagent:${ofbiz.home.dir}/tools/security/notsoserial/notsoserial-1.0-SNAPSHOT.jar"/>
<jvmarg value="-Dnotsoserial.whitelist=${ofbiz.home.dir}/tools/security/notsoserial/empty.txt"/>
<jvmarg value="-Dnotsoserial.dryrun=${ofbiz.home.dir}/tools/security/notsoserial/is-deserialized.txt"/>
<jvmarg value="-Dnotsoserial.trace=${ofbiz.home.dir}/tools/security/notsoserial/deserialize-trace.txt"/>
<arg value="start-batch"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<target name="start-debug"
description="Start OFBiz in debugging mode. It uses the 8091 port by default. Use -Dportoffset=portNumber to shift all ports with the portNumber value.">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="-Xnoagent"/>
<jvmarg value="-Djava.compiler=NONE"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8091"/>
<arg value="start-debug"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<target name="start-pos"
description="Start OFBiz POS (Point of sale). Use -Dportoffset=portNumber to shift all ports with the portNumber value.">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="pos"/>
<arg value="-portoffset=${portoffset}"/><!-- Not sure this makes sense and is useful at all -->
</java>
</target>
<target name="start-pos-secure"
description="Same than start-pos but pre-loading the notsoserial Java agent (from tools/security/notsoserial) to protect OFBiz from the Java deserialization vulnerability">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="-javaagent:${ofbiz.home.dir}/tools/security/notsoserial/notsoserial-1.0-SNAPSHOT.jar"/>
<jvmarg value="-Dnotsoserial.whitelist=${ofbiz.home.dir}/tools/security/notsoserial/empty.txt"/>
<jvmarg value="-Dnotsoserial.dryrun=${ofbiz.home.dir}/tools/security/notsoserial/is-deserialized.txt"/>
<jvmarg value="-Dnotsoserial.trace=${ofbiz.home.dir}/tools/security/notsoserial/deserialize-trace.txt"/>
<arg value="pos"/>
<arg value="-portoffset=${portoffset}"/><!-- Not sure this makes sense and is useful at all -->
</java>
</target>
<target name="start-both"
description="Start OFBiz in both Web and POS (Point of sale) modes. Use -Dportoffset=portNumber to shift all ports with the portNumber value.">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="both"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<target name="start-both-secure"
description="Same than start-both but pre-loading the notsoserial Java agent (from tools/security/notsoserial) to protect OFBiz from the Java deserialization vulnerability">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<jvmarg value="-javaagent:${ofbiz.home.dir}/tools/security/notsoserial/notsoserial-1.0-SNAPSHOT.jar"/>
<jvmarg value="-Dnotsoserial.whitelist=${ofbiz.home.dir}/tools/security/notsoserial/empty.txt"/>
<jvmarg value="-Dnotsoserial.dryrun=${ofbiz.home.dir}/tools/security/notsoserial/is-deserialized.txt"/>
<jvmarg value="-Dnotsoserial.trace=${ofbiz.home.dir}/tools/security/notsoserial/deserialize-trace.txt"/>
<arg value="both"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<target name="stop"
description="Stop OFBiz. Use -Dportoffset=portNumber to shift all ports with the portNumber value.">
<java jar="ofbiz.jar" fork="true">
<arg value="-shutdown"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<target name="status"
description="Display status of OFBiz. Use -Dportoffset=portNumber to shift all ports with the portNumber value.">
<java jar="ofbiz.jar" fork="true">
<arg value="-status"/>
<arg value="-portoffset=${portoffset}"/>
</java>
</target>
<!-- ================================================================== -->
<!-- Setup OFBiz Data -->
<!-- ================================================================== -->
<target name="load-demo" depends="build"
description="Load all data; meant for generic OFBiz development, testing, demonstration, etc purposes">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
</java>
</target>
<target name="load-demo-multitenant" depends="build"
description="Load all data needed for the multi-tenancy demonstration. Caution: this creates three databases, with each one loaded with all demo data.">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
</java>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=default#DEMO1"/>
</java>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=default#DEMO2"/>
</java>
</target>
<!-- By Ted Zheng -->
<target name="load-demo-by-tenantId" depends="build"
description="Load all data needed for the multi-tenancy demonstration. Caution: this creates three databases, with each one loaded with all demo data.">
<input addproperty="tenantId" message="Enter Id for the tenant: "/>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=default#${tenantId}"/>
</java>
</target>
<target name="load-seed" depends="build"
description="Load ONLY the seed data (not seed-initial, demo, ext* or anything else); meant for use after an update of the code to reload the seed data as it is generally maintained along with the code and needs to be in sync for operation">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="readers=seed"/>
</java>
</target>
<target name="load-extseed" depends="build"
description="Load seed, seed-initial and ext data; meant for manual/generic testing, development, or going into production with a derived system based on stock OFBiz where the ext data basically replaces the demo data">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="readers=seed,seed-initial,ext"/>
</java>
</target>
<target name="load-exttest" depends="build"
description="Load seed, seed-initial, ext and ext-test data; meant for automated testing with a derived system based on stock OFBiz">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="readers=seed,seed-initial,ext,ext-test"/>
</java>
</target>
<target name="load-readers" depends="build"
description='Load data using the command line argument data-readers that takes a comma separated list of readers (seed, seed-initial, demo, ext, ext-test, ext-demo). On Windows XP (at least) you need top wrap the parameters in double-quotes. For instance: ant load-readers "-Ddata-readers=seed,seed-initial,ext"'>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="readers=${data-readers}"/>
</java>
</target>
<target name="load-file" depends="build"
description="Load data using the command line argument 'data-file' to load data from a given file using the 'default' delegator or a delegator specified in the command line argument 'delegator'">
<property name="delegator" value="default"/>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=${delegator}"/>
<arg value="file=${data-file}"/>
</java>
</target>
<!-- =================================
target: load-tenant
================================= -->
<target name="load-tenant"
depends="build,load-tenant-all,load-tenant-reader,load-tenant-component-all,load-tenant-component-reader"
description="Load data using tenantId, syntax eg: ant load-tenant -DtenantId=DEMO1 (needs multitenant=Y in general.properties)">
</target>
<target name="check-tenant-id">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="readers=tenant"/>
</java>
<condition property="hasTenant">
<and>
<length string="${tenantId}" trim="true" when="greater" length="0"/>
<not>
<contains string="${tenantId}" substring="tenantId"/>
</not>
<or>
<length string="${component}" trim="true" when="equal" length="0"/>
<contains string="${component}" substring="component"/>
</or>
</and>
</condition>
<condition property="hasTenantComponent">
<and>
<length string="${tenantId}" trim="true" when="greater" length="0"/>
<not>
<contains string="${tenantId}" substring="tenantId"/>
</not>
<length string="${component}" trim="true" when="greater" length="0"/>
<not>
<contains string="${component}" substring="component"/>
</not>
</and>
</condition>
</target>
<target name="check-tenant-reader" depends="check-tenant-id" if="hasTenant">
<condition property="hasReader">
<and>
<length string="${data-readers}" trim="true" when="greater" length="0"/>
<not>
<contains string="${data-readers}" substring="data-readers"/>
</not>
</and>
</condition>
<condition property="noReader">
<or>
<length string="${data-readers}" trim="true" when="equal" length="0"/>
<contains string="${data-readers}" substring="data-readers"/>
</or>
</condition>
</target>
<target name="load-tenant-all" depends="check-tenant-reader" if="noReader">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=default#${tenantId}"/>
</java>
</target>
<target name="load-tenant-reader" depends="check-tenant-reader" if="hasReader">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=default#${tenantId}"/>
<arg value="readers=${data-readers}"/>
</java>
</target>
<!-- load-tenant-component -->
<target name="load-tenant-component" if="hasTenantComponent" depends="check-tenant-id">
<condition property="hasComponentReader">
<and>
<length string="${data-readers}" trim="true" when="greater" length="0"/>
<not>
<contains string="${data-readers}" substring="data-readers"/>
</not>
</and>
</condition>
<condition property="noComponentReader">
<or>
<length string="${data-readers}" trim="true" when="equal" length="0"/>
<contains string="${data-readers}" substring="data-readers"/>
</or>
</condition>
</target>
<target name="load-tenant-component-all" depends="load-tenant-component" if="noComponentReader">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=default#${tenantId}"/>
<arg value="component=${component}"/>
</java>
</target>
<target name="load-tenant-component-reader" depends="load-tenant-component" if="hasComponentReader">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=default#${tenantId}"/>
<arg value="readers=${data-readers}"/>
<arg value="component=${component}"/>
</java>
</target>
<!-- =================================
target: load-all-tenants
================================= -->
<target name="load-all-tenants" depends="build,load-tenants-all,load-tenants-reader"
description="Load data for all tenants, syntax eg: ant load-all-tenants (needs multitenant=Y in general.properties)">
</target>
<target name="check-tenants-reader">
<property name="delegator" value="all-tenants"/>
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="readers=tenant"/>
</java>
<condition property="hasReader">
<and>
<length string="${data-readers}" trim="true" when="greater" length="0"/>
<not>
<contains string="${data-readers}" substring="data-readers"/>
</not>
</and>
</condition>
<condition property="noReader">
<or>
<length string="${data-readers}" trim="true" when="equal" length="0"/>
<contains string="${data-readers}" substring="data-readers"/>
</or>
</condition>
</target>
<target name="load-tenants-all" depends="check-tenants-reader" if="noReader">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="delegator=${delegator}"/>
</java>
</target>
<target name="load-tenants-reader" depends="check-tenants-reader" if="hasReader">
<java jar="ofbiz.jar" fork="true">
<jvmarg value="${memory.initial.param}"/>
<jvmarg value="${memory.max.param}"/>
<arg value="load-data"/>
<arg value="readers=${data-readers}"/>
<arg value="delegator=${delegator}"/>
</java>
</target>
<!-- =================================
target: create-tenant
================================= -->
<target name="create-tenant"
depends="create-tenant-on-Derby,create-tenant-on-MySQL,create-tenant-on-Oracle,create-tenant-on-PostgreSQL"
description="Create a new tenant in your environment, create the delegator, load initial data with admin-user and password (needs multitenant=Y in general.properties)">
<tstamp/>
</target>
<!-- description="This creates entity Tenant and TenantDataSource in default, installs data in the delegator and creates the admin-user and password for the tenant"
sub-target of create-tenant, can't used alone => no description, to not clutter "ant -p" -->
<target name="get-tenant-data">
<input addproperty="tenantId" message="Enter Id for the tenant: "/>
<input addproperty="tenantName" message="Enter name for tenant: "/>
<input addproperty="domainName" message="Enter domain name for tenant (Optional): "/>
<input addproperty="data-readers" message="Enter data to install.
Choices are e.g. seed,seed-initial,ext,demo.
Multipe datasets must be separated with a comma: "/>
<input addproperty="db-Platform"
message="Select your default database platform, D = Derby,M = MySQL, O = Oracle, P = PostgreSQL"
validargs="D,M,O,P"/>
<echo message="Please make sure that the driver of the platform is installed and that the databases have been created (in function of the entityengine.xml datasource-names)"/>
<input addproperty="db-IP" message="Enter IP address of the database server (you may add a port number)"/>
<input addproperty="db-User" message="Enter userID of database user: "/>
<input addproperty="db-Password" message="Enter password of database user: "/>
<condition property="isDerby">
<equals arg1="${db-Platform}" arg2="D"/>
</condition>
<condition property="isMySQL">
<equals arg1="${db-Platform}" arg2="M"/>
</condition>
<condition property="isOracle">
<equals arg1="${db-Platform}" arg2="O"/>
</condition>
<condition property="isPostgreSQL">
<equals arg1="${db-Platform}" arg2="P"/>
</condition>
<antcall target="tenant-data-entry"/>
</target>
<!-- description="Creates tenant data and instance"
sub-target of create-tenant, can't used alone => no description, to not clutter "ant -p" -->
<target name="create-tenant-on-Derby" depends="get-tenant-data" if="isDerby">
<echo message="Installing on Derby"/>
<!-- Below code will handle the case of optional domain name. It will remove the TenantDomainName entry from tmpTenantData.xml file
if domain name is empty, so that record would not get created. -->
<copy file="${basedir}/framework/resources/templates/AdminNewTenantData-Derby.xml"
tofile="runtime/tmp/tmpTenantData.xml"/>
<if>
<equals arg1="${domainName}" arg2=""/>
<then>
<replace file="runtime/tmp/tmpTenantData.xml">
<replacetoken>
<![CDATA[<TenantDomainName tenantId="@tenantId@" domainName="@domainName@" />]]></replacetoken>
<replacevalue><![CDATA[]]></replacevalue>
</replace>
</then>
</if>
<copy file="runtime/tmp/tmpTenantData.xml" tofile="runtime/tmp/tmpFilteredTenantData.xml">
<filterset>
<filter token="tenantId" value="${tenantId}"/>
<filter token="tenantName" value="${tenantName}"/>
<filter token="domainName" value="${domainName}"/>
</filterset>
</copy>
<antcall target="load-file">
<param name="data-file" value="runtime/tmp/tmpFilteredTenantData.xml"/>
</antcall>
<delete file="runtime/tmp/tmpTenantData.xml"/>
<delete file="runtime/tmp/tmpFilteredTenantData.xml"/>
<antcall target="load-tenant-data-readers"/>
<antcall target="load-tenant-admin-user-login">
<param name="userLoginId" value="${tenantId}-admin"/>
<param name="delegatorId" value="default#${tenantId}"/>
</antcall>
</target>
<!-- description="Creates tenant data and instance. Don't forget db driver(s) and already created DBs in function of the entityengine.xml datasource-names"
sub-target of create-tenant, can't used alone => no description, to not clutter "ant -p" -->
<target name="create-tenant-on-MySQL" depends="get-tenant-data" if="isMySQL">
<echo message="Installing on MySQL"/>
<!-- Below code will handle the case of optional domain name. It will remove the TenantDomainName entry from tmpTenantData.xml file
if domain name is empty, so that record would not get created. -->
<copy file="${basedir}/framework/resources/templates/AdminNewTenantData-MySQL.xml"
tofile="runtime/tmp/tmpTenantData.xml"/>
<if>
<equals arg1="${domainName}" arg2=""/>
<then>
<replace file="runtime/tmp/tmpTenantData.xml">
<replacetoken>
<![CDATA[<TenantDomainName tenantId="@tenantId@" domainName="@domainName@" />]]></replacetoken>
<replacevalue><![CDATA[]]></replacevalue>
</replace>
</then>
</if>
<copy file="runtime/tmp/tmpTenantData.xml" tofile="runtime/tmp/tmpFilteredTenantData.xml">
<filterset>
<filter token="tenantId" value="${tenantId}"/>