forked from ilscipio/scipio-erp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmacros.xml
799 lines (733 loc) · 42.1 KB
/
macros.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
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is subject to the terms and conditions defined in the
files 'LICENSE' and 'NOTICE', which are part of this source
code package.
-->
<project name="Ant - Macros"
xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- SCIPIO: NOTE: Despite the filename, this is used for all types of definitions
common to both main build.xml, component build.xml, and limited support for
individual component build.xml invocation in some cases. -->
<!-- ================================================================== -->
<!-- Generic Ant macros (SCIPIO) -->
<!-- ================================================================== -->
<macrodef name="condition-ext" description="Custom emulation of ant condition task for ant-contrib var assignments, with unset support">
<attribute name="var" default=""/>
<attribute name="property" default=""/>
<attribute name="noneValue" default="__NONE__"/><!-- Ant macrodef workaround -->
<attribute name="value" default="@{noneValue}"/>
<attribute name="unset" default="false"/>
<attribute name="else" default="@{noneValue}"/>
<attribute name="else-unset" default="false"/>
<element name="if-condition" optional="false" implicit="true"/>
<sequential>
<if><!-- SCIPIO: 2018-05-08: backward compat for old scripts -->
<if-condition/>
<then>
<if>
<equals arg1="@{unset}" arg2="true"/>
<then>
<if>
<not><equals arg1="@{var}" arg2=""/></not>
<then>
<!-- NOTE: must unset first, in case using this to override a property (see ant-contrib docs) -->
<var name="@{var}" unset="true"/>
</then>
<else>
<var name="@{property}" unset="true"/>
</else>
</if>
</then>
<elseif>
<not><equals arg1="@{value}" arg2="__NONE__"/></not>
<then>
<if>
<not><equals arg1="@{var}" arg2=""/></not>
<then>
<!-- NOTE: must unset first, in case using this to override a property (see ant-contrib docs) -->
<var name="@{var}" unset="true"/>
<var name="@{var}" value="@{value}"/>
</then>
<else>
<var name="@{property}" unset="true"/>
<property name="@{property}" value="@{value}"/>
</else>
</if>
</then>
</elseif>
</if>
</then>
<else>
<if>
<equals arg1="@{else-unset}" arg2="true"/>
<then>
<if>
<not><equals arg1="@{var}" arg2=""/></not>
<then>
<!-- NOTE: must unset first, in case using this to override a property (see ant-contrib docs) -->
<var name="@{var}" unset="true"/>
</then>
<else>
<var name="@{property}" unset="true"/>
</else>
</if>
</then>
<elseif>
<not><equals arg1="@{else}" arg2="__NONE__"/></not>
<then>
<if>
<not><equals arg1="@{var}" arg2=""/></not>
<then>
<!-- NOTE: must unset first, in case using this to override a property (see ant-contrib docs) -->
<var name="@{var}" unset="true"/>
<var name="@{var}" value="@{else}"/>
</then>
<else>
<var name="@{property}" unset="true"/>
<property name="@{property}" value="@{else}"/>
</else>
</if>
</then>
</elseif>
</if>
</else>
</if>
</sequential>
</macrodef>
<!-- ================================================================== -->
<!-- Requirements -->
<!-- ================================================================== -->
<property name="minimumantversion" value="1.9.1"/>
<!-- FOR DEVELOPERS:
If you are a developer using an IDE-provided Ant version and certain there are no problems,
you can eliminate the provided ant version warning by uncommenting the following line or setting this property: -->
<!--<property name="antlib.check.ok" value="true"/>-->
<!-- SCIPIO: 2018-04-04: The ant and JDK version checks are now only done once with include guard
NOTE: the macro call is further below due to ant-contrib use -->
<macrodef name="check-reqs">
<sequential>
<if>
<not><isset property="checkreqs.ran"/></not>
<then>
<antversion property="antversion" atleast="${minimumantversion}"/>
<fail unless="antversion">ANT VERSION: Scipio build requires minimum ant version: ${minimumantversion}
You are running: ${ant.version} (${ant.core.lib})
If you are running from command line, an ant jar is provided with Scipio (framework/base/lib/ant/);
using a system ant installation is not recommended, as such configurations may not be tested.
From command line, Scipio build should be invoked using the provided ant launch scripts in project root:
* Linux, Mac, Cygwin, Windows Git Bash: ./ant [target]
* Windows (no Bash, through ant.bat): ant [target]</fail>
<condition property="antlib.check.ok">
<contains substring="framework${file.separator}base${file.separator}lib${file.separator}ant${file.separator}" string="${ant.core.lib}"/>
</condition>
<if>
<not><isset property="antlib.check.ok"/></not>
<then>
<path id="antlib.provided.jar.full">
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant/" includes="ant-*-ant.jar"/>
</path>
<property name="antlib.provided.jar.rel" value="${toString:antlib.provided.jar.full}" relative="true" basedir="${ofbiz.home.dir}"/>
<!--<antversion property="providedantversion.ok" exactly="${providedantversion}"/>-->
<echo level="warning">WARNING: The ant jar executing is not the one provided with Scipio (${antlib.provided.jar.rel})
You are running: ${ant.version} (${ant.core.lib})
From command line, Scipio build should be invoked using the provided ant launch scripts in project root:
* Linux, Mac, Cygwin, Windows Git Bash: ./ant [target]
* Windows (no Bash, through ant.bat): ant [target]
(Developers can eliminate this message for IDEs by setting the antlib.check.ok property to true)</echo>
</then>
</if>
<!-- SCIPIO: 2017-09-06: JDK version minimum requirement is now 1.8 -->
<condition property="javaatleast18">
<not>
<matches pattern="^1\.[0-7]($|\..*)" string="${ant.java.version}"/>
</not>
</condition>
<fail unless="javaatleast18" message="Please upgrade java to at least 1.8. Current Java version is ${ant.java.version}"/>
<property name="checkreqs.ran" value="true"/>
</then>
</if>
</sequential>
</macrodef>
<target name="check-reqs">
<check-reqs/>
</target>
<!-- ================================================================== -->
<!-- Common/generic defs for all builds -->
<!-- ================================================================== -->
<dirname property="ofbiz.home.dir" file="${ant.file.Ant - Macros}"/>
<path id="local.class.path"/>
<patternset id="src.inc.set">
<include name="**/*.java"/>
</patternset>
<patternset id="src.exc.set"/>
<!-- ================================================================== -->
<!-- Ant extensions (taskdefs) -->
<!-- ================================================================== -->
<!-- ant-contrib -->
<path id="ant-contrib.class.path">
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant/" includes="ant-contrib-*.jar"/>
</path>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="ant-contrib.class.path"/>
<!-- trigger the requirements check (requires ant-contrib) -->
<check-reqs/>
<!-- ivy (SCIPIO) (see ivy-init for taskdef) -->
<property name="ivy.settings.file" value="${ofbiz.home.dir}/ivy/ivysettings.xml"/>
<property name="lib.general.ivyfile" value="${ofbiz.home.dir}/ivy/ivy.xml"/>
<property name="lib.comp.base.ivyfile" value="${ofbiz.home.dir}/framework/base/ivy.xml"/>
<path id="lib.ivy.class.path">
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant/" includes="ivy-*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="oro-*.jar"/>
</path>
<!-- groovy (SCIPIO: NOTE: 2018-03-20: see groovy-init for taskdef) -->
<path id="groovy.class.path">
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="groovy-*.jar"/>
</path>
<!-- rhino -->
<path id="rhino.class.path">
<fileset dir="${ofbiz.home.dir}/extension/rhino/lib/" includes="js-*.jar"/>
</path>
<!-- junit -->
<path id="junit.class.path">
<!-- SCIPIO: 2017-02-02: The junit JAR itself should now be explicitly specified, as may miss from classpath or wrong one on classpath -->
<fileset dir="${ofbiz.home.dir}/framework/base/lib" includes="junit-*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant/" includes="ant-apache-bsf-*.jar"/>
<!-- scripting (previously under base/lib/scripting) -->
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="antlr-*.jar"/>
<!-- SCIPIO: 2018-07-06: junit should not need this
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant-ext" includes="asm-*.jar"/>-->
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="bsf-*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="bsh-*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="groovy-*.jar"/>
<!-- SCIPIO: removed
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="jython-*.jar"/>-->
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="oro-*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="hamcrest-*.jar"/><!-- SCIPIO: 2018-03-27: hamcrest-core dep for junit -->
</path>
<!-- cobertura -->
<path id="cobertura.class.path">
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant-opt/cobertura" includes="*.jar"/>
<!-- SCIPIO: 2018-07-06: for now, included under ant-opt/cobertura (what else would use asm?)
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant-ext" includes="asm-*.jar"/>-->
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="junit-*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="log4j-*.jar"/>
<!-- SCIPIO: version compability problems
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="slf4j-api-*.jar"/>-->
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="oro-*.jar"/>
</path>
<!-- jacoco -->
<path id="jacoco.class.path">
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant-opt/jacoco" includes="*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="junit-*.jar"/>
<fileset dir="${ofbiz.home.dir}/framework/base/lib/" includes="log4j-*.jar"/>
</path>
<path id="jacoco.agent.class.path">
<fileset dir="${ofbiz.home.dir}/framework/base/lib/ant-opt/jacoco" includes="*agent*.jar"/>
</path>
<!-- ================================================================== -->
<!-- Common build macros/presets -->
<!-- ================================================================== -->
<presetdef name="default-javac">
<javac debug="on" deprecation="on" destdir="${build.dir}/classes" srcdir="${src.dir}" classpathref="local.class.path">
<patternset refid="src.inc.set"/>
<patternset refid="src.exc.set"/>
</javac>
</presetdef>
<presetdef name="javac17">
<default-javac compiler="javac1.7" target="1.7" source="1.7" encoding="UTF-8" includeantruntime="false">
<compilerarg value="-Xlint:-path"/>
<!--
Please leave this line here. It makes it easier to enable/disable it.
<compilerarg value="-Xlint:unchecked"/>
-->
</default-javac>
</presetdef>
<!-- SCIPIO: new explicit target for java 1.8-compatibility -->
<presetdef name="javac18">
<default-javac compiler="javac1.8" target="1.8" source="1.8" encoding="UTF-8" includeantruntime="false">
<compilerarg value="-Xlint:-path"/>
<!--
Please leave this line here. It makes it easier to enable/disable it.
<compilerarg value="-Xlint:unchecked"/>
-->
</default-javac>
</presetdef>
<presetdef name="default-javadoc">
<javadoc classpathref="local.class.path"
destdir="${build.dir}/javadocs"
windowtitle="Apache OFBiz - ${desc}"
useexternalfile="yes"
maxmemory="512M"
encoding="UTF-8"
packagenames="org.ofbiz.*">
<fileset dir="${basedir}" defaultexcludes="yes">
<include name="**/*.java"/>
<exclude name="**/ControlApplet.java"/>
<exclude name="**/ShipmentScaleApplet.java"/>
<exclude name="**/test/"/>
<exclude name="**/cybersource/"/>
<exclude name="**/PayPalServices.java"/>
<exclude name="**/ideal/"/>
<exclude name="**/orbital/"/>
<exclude name="**/securepay/"/>
<exclude name="**/verisign/"/>
<exclude name="**/JREntityListIteratorDataSource.java"/>
<exclude name="**/JRMapCollectionDataSource.java"/>
<exclude name="**/openoffice/"/>
<exclude name="**/JasperReportsXmlViewHandler.java"/>
<exclude name="**/JasperReportsJXlsViewHandler.java"/>
<exclude name="**/JasperReportsPoiXlsViewHandler.java"/>
</fileset>
<link href="http://java.sun.com/javase/7/docs/api/" offline="true" packagelistLoc="${ofbiz.home.dir}/tools/api-java17"/>
</javadoc>
</presetdef>
<!-- SCIPIO: NOTE: 2018-03-20: This requires groovy-init task in main build -->
<macrodef name="default-groovyc">
<sequential>
<groovyc destdir="${build.dir}/classes" srcdir="${src.dir}">
<classpath>
<path refid="local.class.path"/>
<pathelement path="${build.dir}/classes"/>
</classpath>
</groovyc>
</sequential>
</macrodef>
<macrodef name="main-jar">
<attribute name="jarfile" default="${build.dir}/lib/${name}.jar"/>
<element name="main-pattern" optional="true"/>
<element name="main-elements" optional="true" />
<sequential>
<jar jarfile="@{jarfile}">
<fileset dir="${build.dir}/classes">
<exclude name="**/test" />
<exclude name="**/test/*" />
<main-pattern />
</fileset>
<fileset dir="${src.extra.dir}">
<and>
<not>
<or>
<filename name="**/test"/>
<filename name="**/test/*"/>
</or>
</not>
<selector refid="src-extra-set"/>
</and>
</fileset>
<!-- now add the NOTICE and LICENSE files to allow the jar file to be distributed alone -->
<zipfileset dir="${ofbiz.home.dir}" prefix="META-INF" includes="NOTICE,LICENSE"/>
<main-elements/>
</jar>
</sequential>
</macrodef>
<macrodef name="test-jar">
<attribute name="jarfile" default="${build.dir}/lib/${name}-test.jar"/>
<element name="test-selector" optional="true"/>
<element name="test-elements" optional="true"/>
<sequential>
<jar jarfile="@{jarfile}">
<fileset dir="${build.dir}/classes">
<or>
<filename name="**/test"/>
<filename name="**/test/*"/>
<test-selector/>
</or>
</fileset>
<fileset dir="${src.dir}">
<and>
<filename name="**/test/*"/>
<or>
<test-selector/>
<selector refid="src-extra-set"/>
</or>
</and>
</fileset>
<zipfileset dir="${ofbiz.home.dir}" prefix="META-INF" includes="NOTICE,LICENSE"/>
<test-elements/>
</jar>
</sequential>
</macrodef>
<!-- SCIPIO: NOTE: This macro is enhanced to supported nested implicit iterate-subant-args for the subant call -->
<macrodef name="iterate">
<attribute name="filelist" default="subdirs"/>
<attribute name="target" default=""/>
<attribute name="inheritall" default="false"/>
<element name="iterate-subant-args" optional="yes" implicit="yes"/>
<sequential>
<subant target="@{target}" inheritall="@{inheritall}">
<propertyset refid="ofbiz.subbuild.props.pass"/>
<!-- SCIPIO: new 2017-02-01 -->
<iterate-subant-args />
<filelist refid="@{filelist}"/>
</subant>
</sequential>
</macrodef>
<presetdef name="externalsubant">
<subant inheritall="false">
<!-- SCIPIO: defined in build.xml
<propertyset>
<propertyref name="ofbiz.home.dir"/>
</propertyset>-->
<propertyset refid="ofbiz.subbuild.props.pass"/>
</subant>
</presetdef>
<!-- ================================================================== -->
<!-- SCIPIO: New common macros/presets -->
<!-- ================================================================== -->
<!-- SCIPIO: Build invoker with automatic dependency resolution.
Fetches the component.build.dependencies filelist from each component within a given component directory
and resolves the resulting dependency graph to determine a build order, mirroring the same
algorithm now used for the scipio-component.xml/scipio-theme.xml/ofbiz-component.xml depends-on functionality (new 2017-01-17).
See also the "get-component-build-deps" target (called by this macro). -->
<macrodef name="dep-subant">
<attribute name="dir" default=""/>
<attribute name="target" default=""/>
<attribute name="auto-build-tools" default="true"/>
<sequential>
<!-- Old stock code (arbitrary build order)
<externalsubant target="@{target}">
<fileset dir="@{dir}" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
</fileset>
</externalsubant>-->
<if>
<equals arg1="@{target}" arg2="" trim="true"/>
<then>
<var name="depres.displaytarget" value="build"/>
</then>
<else>
<var name="depres.displaytarget" value="@{target}"/>
</else>
</if>
<if>
<equals arg1="@{auto-build-tools}" arg2="true"/>
<then>
<var name="scipio.buildtools.present" unset="true"/>
<available file="${ofbiz.home.dir}/tools/misc/scipio-build-tools.jar" property="scipio.buildtools.present" />
<if>
<not><isset property="scipio.buildtools.present"/></not>
<then>
<echo message="scipio-build-tools.jar not found (required for sub-builds) - triggering build..."/>
<antcall target="build-scipio-build-tools"/>
</then>
</if>
</then>
</if>
<var name="depres.depgraph" unset="true"/>
<var name="depres.depgraph" value="" />
<var name="depres.topdirname" unset="true"/>
<basename file="@{dir}" property="depres.topdirname"/>
<echo message=""/>
<echo message="${depres.topdirname}: Starting automatic build dependency resolution for ${depres.displaytarget} task..." />
<!-- Build depgraph: read the component.build.dependencies values out of each build files and append to depgraph -->
<for param="depres.buildfile">
<path>
<fileset dir="@{dir}" casesensitive="no">
<exclude name="disabled/**"/>
<include name="*/build.xml"/>
</fileset>
</path>
<sequential>
<var name="component.build.dependencies.prop" unset="true"/>
<var name="depres.buildfile.dir" unset="true"/>
<var name="depres.buildfile.name" unset="true"/>
<var name="depres.buildfile.relative" unset="true"/>
<dirname file="@{depres.buildfile}" property="depres.buildfile.dir"/>
<basename file="@{depres.buildfile}" property="depres.buildfile.name"/>
<property name="depres.buildfile.relative" value="@{depres.buildfile}" relative="true" />
<!-- Special call using ant-contrib to read dependency list stored in external build file -->
<var name="component.build.dependencies.prop" unset="true" />
<antcallback dir="${depres.buildfile.dir}" target="get-component-build-deps" antfile="${depres.buildfile.name}"
inheritall="false" return="component.build.dependencies.prop">
<!--<property name="basedir" value="${depres.buildfile.dir}"/>-->
<property name="component.build.dependencies.sep" value=","/>
<propertyset refid="ofbiz.subbuild.props.pass"/>
</antcallback>
<if>
<and>
<isset property="component.build.dependencies.prop" />
<not><equals arg1="${component.build.dependencies.prop}" arg2="" trim="true"/></not>
</and>
<then>
<var name="depres.depgraph" value="${depres.depgraph}#${depres.buildfile.relative}=${component.build.dependencies.prop}" />
</then>
<else>
<var name="depres.depgraph" value="${depres.depgraph}#${depres.buildfile.relative}" />
</else>
</if>
</sequential>
</for>
<if>
<or>
<not><isset property="depres.depgraph"/></not>
<equals arg1="${depres.depgraph}" arg2="" trim="true"/>
</or>
<then>
<echo message="${depres.topdirname}: No builds to invoke." />
</then>
<else>
<echo level="verbose" message="Dependency graph for ${depres.topdirname}:${line.separator}${depres.depgraph}" />
<!-- Invoke automatic dependency resolution algorithm -->
<var name="depres.builds" unset="true"/>
<var name="depres.stderr" unset="true"/>
<var name="depres.result" unset="true"/>
<java classname="com.ilscipio.scipio.ce.build.util.DependencyGraph" fork="true"
outputproperty="depres.builds" errorproperty="depres.stderr" resultproperty="depres.result" failonerror="false">
<arg value="-f=resolve-deps-dfs"/>
<!-- function to run -->
<!-- NOTE: using comma as file separator because fileset "includes" attributes uses this -->
<arg value="-do=,"/>
<!-- output delimiter -->
<arg value="-dn=#"/>
<!-- graph entry delimiter -->
<arg value="-de=="/>
<!-- graph element=deps pairs delimiter -->
<arg value="-dd=,"/>
<!-- graph deps delimiter -->
<arg value="-s=false"/>
<!-- strict mode -->
<arg value="-e=false"/>
<!-- use empty values -->
<arg value="-g=${depres.depgraph}"/>
<classpath>
<path location="${ofbiz.home.dir}/tools/misc/scipio-build-tools.jar"/>
<!-- FIXME: non-ideal location for this class -->
</classpath>
</java>
<if>
<not><equals arg1="${depres.result}" arg2="0"/></not>
<then>
<fail message="Error automatically resolving build dependencies for ${depres.topdirname} components:${line.separator}${line.separator}
${depres.stderr}${line.separator}${line.separator}
Please verify the ${depres.topdirname} component build.xml files
for possible errors in the component.build.dependencies build file references."/>
</then>
</if>
<echo message="${depres.topdirname}: Auto-determined build order from dependencies (component.build.dependencies):" />
<echo message="${depres.builds}" />
<!-- Sanity check -->
<if>
<or>
<not><isset property="depres.builds"/></not>
<equals arg1="${depres.builds}" arg2="" trim="true"/>
</or>
<then>
<fail message="Error automatically resolving build dependencies for ${depres.topdirname} components:${line.separator}${line.separator}
${depres.stderr}${line.separator}${line.separator}
Unexpectedly received empty list of builds to iterate."/>
</then>
</if>
<!-- Invoke build files with requested target, in the resolved order (after re-expand comma-separated deresbuilds names to file list) -->
<externalsubant target="@{target}">
<filelist dir="${ofbiz.home.dir}" files="${depres.builds}"/>
</externalsubant>
</else>
</if>
</sequential>
</macrodef>
<!-- SCIPIO: Reads and partly validates the component's component.build.dependencies and returns them
to caller (dep-subant) for automatic dependency resolution.
A component build.xml file may define a build list of dependencies on other components, using the following format:
<filelist dir="." id="component.build.dependencies"> <!- NOTE: MUST be filelist, not fileset ->
<file name="../other1/build.xml" /> <!- explicit build file form: the referenced component build file must exist ->
<file name="../other2" /> <!- abstracted component dependency: component may or may not have a build ->
</filelist>
The component.build.dependencies are file paths which must specify either a component directory
or the project build file within it - you MUST use filelist and NOT fileset to express these.
The second form requires the dependency to have a build, while the first is more abstracted
and will work even if the component has no build project or it is removed (e.g., themes).
Currently (2017-01-18), only dependencies on components within the same component directory (addons, hot-deploy, themes)
have any tangible effect on dependency resolution; reordering is within given component directory only.
Dependencies on components from other, lower-layer components directories which load first are
allowed to appear and may be verified, but will have no functional effect.
NOTE: These build-time dependencies are managed independently from the load-time
dependencies (component loader), and are designated using filesystem paths as opposed
to component names. However, it is recommended to keep the same order for
build-time and load-time dependencies as much as possible.
Currently (2017-01-18), Scipio supports this same directory-focused automatic
dependency resolution for both build-time and load-time resolution; see the description
for the "depends-on" xml element in the following file for the load-time mechanism:
component://base/dtd/ofbiz-component.xsd
FIXME?: get-component-build-deps must currently be defined in macros.xml due to theme patterns... -->
<macrodef name="read-component-build-deps">
<!--
NOTE: Caller must specify:
* component.build.dependencies.sep (context-dependent)
* ofbiz.home.dir
-->
<sequential>
<if>
<isreference refid="component.build.dependencies"/>
<then>
<var name="component.build.dependencies.prop" unset="true" />
<pathconvert property="component.build.dependencies.prop" refid="component.build.dependencies"
pathsep="${component.build.dependencies.sep}" setonempty="true">
<!-- DEV NOTE: see https://ant.apache.org/manual/Tasks/script.html for language details -->
<scriptmapper language="javascript"><![CDATA[
var proj = self.getProject();
var doFail = function(msg) {
var failTask = proj.createTask("fail");
failTask.setMessage("Project " + proj.getName() + ": component.build.dependencies: " + msg);
failTask.perform();
};
var echoMsg = function(msg) {
var echoTask = proj.createTask("echo");
echoTask.setMessage("Project " + proj.getName() + ": component.build.dependencies: " + msg);
echoTask.perform();
};
var stringEndsWith = function(str, suffix) { // old JS support
return str.indexOf(suffix, str.length - str.length) !== -1;
};
// NOTE: here source is the full path to file
var sourceFile = new java.io.File(source);
if (!sourceFile.exists()) {
doFail("missing or invalid build dependency: path does not exist: " + source);
} else {
var isDepAlreadyHandled = function(targetDep) {
// SPECIAL: 2017-01-18: if the dependency is from a different top component directory
// than the current one, and it is from one already loaded, then discard the dependency
// because it is for all practical purposes already built.
// (we currently do not support global dependency ordering)
var homeDirPath = java.nio.file.Paths.get(proj.getProperty("ofbiz.home.dir"), []);
var getCompDir = function(path) {
var pathPath = java.nio.file.Paths.get(path, []);
return homeDirPath.relativize(pathPath).getName(0);
}
var projCompDir = getCompDir(proj.getProperty("ant.file")); // NOTE: not basedir
var depCompDir = getCompDir(targetDep);
if (depCompDir.compareTo(projCompDir) !== 0) {
var compDirsProp = proj.getProperty("ofbiz.component.dirs");
if (compDirsProp) {
var compDirs = compDirsProp.split(",");
for(var i=0; i < compDirs.length; i++) {
var compDirPath = java.nio.file.Paths.get(compDirs[i], []);
if (projCompDir.compareTo(compDirPath) === 0) {
echoMsg("WARN: build dependency refers to a higher-layer component directory; build may fail: " + targetDep);
return false;
} else if (depCompDir.compareTo(compDirPath) === 0) {
; //echoMsg("build dependency ignored; already handled: " + targetDep);
return true;
}
}
}
}
return false;
};
var validateCommitDep = function(targetDep) {
self.addMappedName(targetDep);
};
if (stringEndsWith(source.toLowerCase(), ".xml") && sourceFile.isFile()) {
// If explicit build file referenced as dependency, interpret as explicit request and don't modify.
// In other words, the component must have a build file, otherwise dependency will fail.
if (!isDepAlreadyHandled(source, sourceFile)) {
validateCommitDep(source, sourceFile);
}
} else if (sourceFile.isDirectory()) {
if (!isDepAlreadyHandled(source, sourceFile)) {
// Here, the reference is to the directory of the component, and we only
// check the dependency if the component has in fact a build file.
// If the component has no build file, we can ignore the build dependency,
// though the component itself must exist.
var dirBuildFile = new java.io.File(sourceFile, "build.xml");
if (dirBuildFile.exists() && dirBuildFile.isFile()) {
validateCommitDep(dirBuildFile.getPath(), dirBuildFile);
} else {
; //echoMsg("build dependency ignored; has no build file: " + sourceFile.getName());
}
}
} else {
doFail("missing or invalid build dependency: invalid path (must be a build.xml file or component directory): " + source);
}
}
]]></scriptmapper>
<!-- strip the full path, make relative to ofbiz base folder (most versatile)
NOTE: this runs after the mapper (even if you list the map before the mapper) -->
<!--<globmapper from="${ofbiz.home.dir}/*" to="*" />-->
<map from="${ofbiz.home.dir}/" to="" />
<!-- this one may be safer for Windows -->
<!--<compositemapper>
<regexpmapper from="^(.*)/?(?<!\.xml)$" to="\1/build.xml" casesensitive="false" />
<regexpmapper from="^(.*\.xml)$" to="\1" casesensitive="false" />
</compositemapper>-->
<!--<filtermapper>
<scriptfilter language="beanshell">
self.setToken(self.getToken().toUpperCase());
</scriptfilter>
</filtermapper>-->
</pathconvert>
<!-- will be read using ant-contrib's antcallback/antfetch
<echo message="${component.build.dependencies.prop}"/>-->
</then>
<else>
<property name="component.build.dependencies.prop" value="" />
</else>
</if>
</sequential>
</macrodef>
<!-- get-component-build-deps: basic form expected by dep-subant
NOTE: We don't really want to define this here... but without it,
a theme not using the new commontheme.xml would need to copy this into its build file
<target name="get-component-build-deps"
description="Reads this component's build dependencies from component.build.dependencies filelist (if any) and prepares for automatic dependency resolution (SCIPIO)">
<read-component-build-deps/>
</target>
-->
<!-- Removes all lib (jar) files from a component lib folder and its subfolders, without removing any subfolders,
with the given exceptions as exclude-pattern -->
<macrodef name="remove-lib-files">
<attribute name="dir"/>
<attribute name="excludes-refid" default=""/>
<attribute name="include" default="**/*.jar"/>
<!-- this takes a <selector> of <filename> elements -->
<element name="patterns" optional="true"/>
<sequential>
<!-- FIXME: ugly duplication, ant kludge (but at least kind to caller) -->
<if>
<isreference refid="@{excludes-refid}"/>
<then>
<!-- never delete empty dirs; never delete .git, .svn, .gitignore, ... -->
<delete includeemptydirs="false" defaultexcludes="true">
<fileset dir="@{dir}">
<include name="@{include}"/>
<patterns />
<!-- instead of taking excludes, take an include list and negate it
<patternset refid="@{excludes-refid}"/>-->
<not><selector refid="@{excludes-refid}"/></not>
</fileset>
</delete>
</then>
<else>
<delete includeemptydirs="false" defaultexcludes="true">
<fileset dir="@{dir}">
<include name="@{include}"/>
<patterns />
</fileset>
</delete>
</else>
</if>
</sequential>
</macrodef>
<!-- ================================================================== -->
<!-- SCIPIO: tasks common to main build and standalone component builds -->
<!-- ================================================================== -->
<target name="groovy-init" depends="ivy-init"><!-- SCIPIO: 2018-03-20: new -->
<if>
<resourcecount when="equal" count="0">
<fileset file="${ofbiz.home.dir}/framework/base/lib/groovy-*.jar"/>
</resourcecount>
<then>
<antcall target="download-groovy"/>
</then>
</if>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovy.class.path"/>
</target>
<target name="download-groovy" depends="ivy-init"><!-- SCIPIO: 2018-03-20: new -->
<ivy:retrieve file="${lib.comp.base.ivyfile}" pattern="framework/base/lib/[artifact]-[revision].[ext]" conf="groovy"/>
</target>
<target name="ivy-init"><!-- SCIPIO: 2017-01-30: new -->
<!-- DEV NOTE: WARN: for performance reasons, this code has to be COPIED into
common.xml#lib-update; keep in sync -->
<taskdef uri="antlib:org.apache.ivy.ant" resource="org/apache/ivy/ant/antlib.xml" classpathref="lib.ivy.class.path"/>
</target>
</project>