-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuild.xml
725 lines (612 loc) · 32.1 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
<project name="xrechnung-validation-configuration" default="compile" basedir=".">
<description>Build the XRechnung validation configuration for ITPLR-KoSIT
validator</description>
<!-- set global default properties for this build -->
<!-- main build directories -->
<property name="src.dir" location="${basedir}/src" />
<property name="lib.dir" location="${basedir}/lib" />
<property name="build.dir" location="${basedir}/build" />
<property name="download.dir" location="${build.dir}/download" />
<property name="dist.dir" location="${basedir}/dist" />
<property name="test.src.dir" location="${src.dir}/test" />
<property name="test.build.dir" location="${build.dir}/test" />
<property name="test.docs.custom.dir" location="${test.src.dir}/custom"></property>
<property name="test.docs.dir" location="${test.build.dir}" />
<property name="test.docs.cen.unit.unexpected.dir" location="${test.docs.dir}/unexpected" />
<property name="test.docs.cen.unit.dir" location="${test.docs.dir}/cen-unit-test" />
<property name="test.docs.integration.dir" location="${test.docs.dir}/integration" />
<property name="testsuite.instances.dir" location="${test.build.dir}/testsuite" />
<!-- Naming -->
<property name="xrechnung.version.major.minor" value="3.0" />
<property name="xrechnung.version.patch" value="2" />
<property name="xrechnung.version"
value="${xrechnung.version.major.minor}.${xrechnung.version.patch}" />
<property name="cen.spec.id" value="urn:cen.eu:en16931:2017" />
<property name="xrechnung.spec.id"
value="${cen.spec.id}#compliant#urn:xeinkauf.de:kosit:xrechnung_${xrechnung.version.major.minor}" />
<property name="xrechnung.extension.id"
value="${xrechnung.spec.id}#conformant#urn:xeinkauf.de:kosit:extension:xrechnung_${xrechnung.version.major.minor}" />
<property name="validator.configuration.version.full" value="2025-01-31-SNAPSHOT" />
<property name="dist.name"
value="validator-configuration-xrechnung_${xrechnung.version}_${validator.configuration.version.full}.zip" />
<!-- 3rd party resources -->
<!-- KoSIT XML Validator -->
<property name="validator.version" value="1.5.0" />
<property name="validator.download.url.prefix"
value="https://github.com/itplr-kosit/validator/releases/download" />
<property name="validator.zip" value="validator-${validator.version}-distribution.zip" />
<!-- Pick by default the standalone distribution -->
<property name="validator.jar" value="validationtool-${validator.version}-standalone.jar" />
<!-- Part of the download path -->
<property name="saxon.url.version" value="9.9" />
<!-- Part of the download path -->
<property name="saxon.file.version" value="9-9-1-8J" />
<!-- the name of the JAR file in the downloaded ZIP file -->
<property name="saxon.jar" value="saxon9he.jar" />
<property name="cii.version" value="D16B" />
<property name="cii.schema.artifact.id" value="D16B_SCRDM__Subset__CII" />
<property name="cii.schema.zip" value="${cii.schema.artifact.id}-${cii.version}.zip" />
<property name="cii.schema.uncoupled.zip" value="d16b-cii-uncoupled.zip" />
<property name="cii.download.url"
value="https://projekte.kosit.org/api/v4/projects/356/packages/maven/de/xeinkauf/${cii.schema.artifact.id}/${cii.version}/${cii.schema.zip}" />
<property name="ubl.version" value="2.1" />
<property name="ubl.download.url.prefix"
value="http://docs.oasis-open.org/ubl/os-UBL-${ubl.version}" />
<property name="ubl.schema.zip" value="UBL-${ubl.version}.zip" />
<property name="ubl.download.url"
value="${ubl.download.url.prefix}/${ubl.schema.zip}" />
<!-- set to "master" if you want latest code -->
<property name="cen.rules.version" value="1.3.12" />
<property name="cen.rules.version.download" value="${cen.rules.version}" />
<property name="cen.download.url.owner" value="ConnectingEurope" />
<property name="cen.download.url.prefix"
value="https://github.com/${cen.download.url.owner}/eInvoicing-EN16931/releases/download/validation-${cen.rules.version}" />
<property name="cen.download.url.ubl"
value="${cen.download.url.prefix}/en16931-ubl-${cen.rules.version.download}.zip" />
<property name="cen.download.url.cii"
value="${cen.download.url.prefix}/en16931-cii-${cen.rules.version.download}.zip" />
<property name="cen.download.url.master.prefix" value="https://github.com/${cen.download.url.owner}/eInvoicing-EN16931/"/>
<!-- XRechnung Schematron Rules section -->
<property name="xr.schematron.version.major.minor" value="2.2" />
<property name="xr.schematron.version.patch" value="0" />
<property name="xr.schematron.version.full"
value="${xr.schematron.version.major.minor}.${xr.schematron.version.patch}" />
<property name="xr.schematron.download.url.prefix"
value="https://github.com/itplr-kosit/xrechnung-schematron/releases/download/release-${xr.schematron.version.full}" />
<property name="xr.schematron.zip"
value="xrechnung-${xrechnung.version}-schematron-${xr.schematron.version.full}.zip" />
<property name="xr.schematron.download.url" value="${xr.schematron.download.url.prefix}/${xr.schematron.zip}" />
<property name="xr.testsuite.version" value="2024-10-31" />
<property name="xr.testsuite.download.url.prefix"
value="https://github.com/itplr-kosit/xrechnung-testsuite/releases/download" />
<!-- root/work directory where KoSIT validationtool expects Schema(s)-and trons -->
<property name="repository.dir" location="${build.dir}" />
<property name="resource.dir" location="${repository.dir}/resources" />
<property name="resource.xr.dir" location="${resource.dir}/xrechnung/${xrechnung.version}/xsl" />
<property name="resource.xsl.cen.ubl"
location="${resource.dir}/ubl/2.1/xsl/EN16931-UBL-validation.xsl" />
<property name="resource.xsl.cen.cii"
location="${resource.dir}/cii/16b/xsl/EN16931-CII-validation.xsl" />
<property name="resource.xsl.xr.ubl"
location="${resource.xr.dir}/XRechnung-UBL-validation.xsl" />
<property name="resource.xsl.xr.cii" location="${resource.xr.dir}/XRechnung-CII-validation.xsl" />
<!-- Resource directories -->
<property name="reports.schema.dir" location="${resource.dir}/xsd" />
<property name="reports.dir" location="${build.dir}/reports" />
<macrodef name="xslt-saxon">
<sequential>
<fail message="Not implemented yet" />
</sequential>
</macrodef>
<macrodef name="schematron-compile" description="Compiles Schematron to XSLT using Saxon">
<attribute name="schematron" description="Schematron file to compile." />
<attribute name="workdir"
description="Base directory in which to download Schematron Skeleton and keep intermediaries." />
<attribute name="outdir" />
<attribute name="insuffix" default="sch" />
<attribute name="saxon.jar" default="${lib.dir}/${saxon.jar}"
description="Location of Saxon jar." />
<attribute name="deleteonexit" default="true"
description="Whether to delete intermediate XSLT files on exit. Note if not deleting, then subsequent runs of macro produce wrong results!" />
<attribute name="schematronbinding" default="xslt2"
description="Which XSLT version to build for." />
<sequential>
<local name="schematron.basename" />
<basename file="@{schematron}" suffix="@{insuffix}" property="schematron.basename" />
<echo message="Compiling '@{schematron}' Schematron with basename='${schematron.basename}'" />
<mkdir dir="@{workdir}" />
<tempfile property="expanded.sch" prefix="expanded" suffix=".sch" destdir="@{workdir}"
deleteonexit="@{deleteonexit}" />
<tempfile property="unabstract.sch" prefix="unabstract" suffix=".sch" destdir="@{workdir}"
deleteonexit="@{deleteonexit}" />
<tempfile property="schematron.xsl" prefix="schematron" suffix=".xsl" destdir="@{workdir}"
deleteonexit="@{deleteonexit}" />
<tempfile property="check-schematron.xsl" prefix="check-schematron" suffix=".xsl"
destdir="@{workdir}" deleteonexit="@{deleteonexit}" />
<!-- Download schematron skeletons -->
<property name="schematron.skeleton.url"
value="https://raw.githubusercontent.com/Schematron/schematron/master/trunk/schematron/code" />
<get src="${schematron.skeleton.url}/iso_dsdl_include.xsl" dest="@{workdir}" verbose="true"
skipexisting="true" usetimestamp="true" httpusecaches="true" />
<get src="${schematron.skeleton.url}/iso_abstract_expand.xsl" dest="@{workdir}" verbose="true"
skipexisting="true" usetimestamp="true" httpusecaches="true" />
<get src="${schematron.skeleton.url}/iso_svrl_for_@{schematronbinding}.xsl" dest="@{workdir}"
verbose="true" skipexisting="true" usetimestamp="true" httpusecaches="true" />
<get src="${schematron.skeleton.url}/iso_schematron_skeleton_for_saxon.xsl" dest="@{workdir}"
verbose="true" skipexisting="true" usetimestamp="true" httpusecaches="true" />
<!-- expand inclusions -->
<xslt style="@{workdir}/iso_dsdl_include.xsl" in="@{schematron}"
out="@{workdir}/${schematron.basename}-expanded.sch" classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
<!-- expand abstract patterns -->
<xslt style="@{workdir}/iso_abstract_expand.xsl"
in="@{workdir}/${schematron.basename}-expanded.sch"
out="@{workdir}/${schematron.basename}-unabstract.sch" classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
<!-- svrl it -->
<xslt style="@{workdir}/iso_svrl_for_@{schematronbinding}.xsl"
in="@{workdir}/${schematron.basename}-unabstract.sch"
out="@{outdir}/${schematron.basename}.xslt" classpath="@{saxon.jar}">
<factory name="net.sf.saxon.TransformerFactoryImpl" />
<param name="generate-fired-rule" expression="false" />
<param name="full-path-notation" expression="3" />
</xslt>
<echo message="finished schematron compile output to @{outdir}/${schematron.basename}.xslt" />
</sequential>
</macrodef>
<target name="init" description="Initializes build directory structure and ISO timestamp">
<!-- sets the property cen.master.target if version is set to master and the only downloads from master instaead of release. -->
<condition property="cen.master.target">
<equals arg1="${cen.rules.version}" arg2="master" />
</condition>
<!-- Create timestamps -->
<tstamp>
<format property="build.date" pattern="yyyy-MM-dd" />
</tstamp>
<echo>Build date: ${build.date}</echo>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build.dir}" />
<mkdir dir="${download.dir}" />
<mkdir dir="${lib.dir}" />
<mkdir dir="${dist.dir}" />
</target>
<target name="prepare-saxon" depends="init"
description="Download Saxon-HE and add jar to library directory">
<get
src="https://sourceforge.net/projects/saxon/files/Saxon-HE/${saxon.url.version}/SaxonHE${saxon.file.version}.zip/download"
dest="${download.dir}/SaxonHE${saxon.file.version}.zip" verbose="true" skipexisting="true"
usetimestamp="true" />
<unzip src="${download.dir}/SaxonHE${saxon.file.version}.zip" dest="${lib.dir}">
<patternset>
<include name="**/${saxon.jar}" />
</patternset>
<flattenmapper />
</unzip>
</target>
<target name="delete-saxon" depends="init" description="Remove downloaded Saxon-HE stuff">
<delete file="${download.dir}/SaxonHE${saxon.file.version}.zip" />
<delete file="${lib.dir}/${saxon.jar}" />
</target>
<target name="retrieve-validator-from-local-build" depends="init" if="develop.local.validator">
<get src="${validator.download.url.prefix}/target/${validator.zip}" dest="${download.dir}/"
verbose="true" skipexisting="true" usetimestamp="true" />
</target>
<target name="retrieve-validator-from-github-release" depends="init"
unless="develop.local.validator">
<property name="download.url.full"
value="${validator.download.url.prefix}/v${validator.version}/${validator.zip}" />
<echo message="Retrieving validator version=${validator.version} from ${download.url.full}" />
<get src="${download.url.full}" dest="${download.dir}" verbose="true" skipexisting="true"
usetimestamp="true" />
</target>
<target name="retrieve-validator"
depends="init, retrieve-validator-from-local-build, retrieve-validator-from-github-release">
<!-- add check something was downloaded -->
</target>
<target name="provide-validator" depends="init, retrieve-validator"
description="Download KoSIT validation tool and add jar to library directory">
<echo message="Unpacking Validator resources" />
<unzip src="${download.dir}/${validator.zip}" dest="${lib.dir}">
<patternset>
<include name="**/${validator.jar}" />
</patternset>
<flattenmapper />
</unzip>
<unzip src="${lib.dir}/${validator.jar}" dest="${resource.dir}">
<patternset>
<include name="xsd/scenarios.xsd" />
</patternset>
</unzip>
</target>
<property name="xr.testsuite.zip"
value="xrechnung-${xrechnung.version}-testsuite-${xr.testsuite.version}.zip" />
<target name="retrieve-xr-testsuite-from-local-build" depends="init"
if="develop.local.xr.testsuite">
<get src="${xr.testsuite.download.url.prefix}/${xr.testsuite.zip}" dest="${download.dir}"
verbose="true" skipexisting="false" usetimestamp="false" httpusecaches="false" />
</target>
<target name="retrieve-xr-testsuite-from-github-release" depends="init-test"
unless="develop.local.xr.testsuite">
<get
src="${xr.testsuite.download.url.prefix}/release-${xr.testsuite.version}/${xr.testsuite.zip}"
dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true" />
</target>
<target name="retrieve-xr-testsuite"
depends="init-test, retrieve-xr-testsuite-from-local-build, retrieve-xr-testsuite-from-github-release">
<!-- add check something was downloaded -->
</target>
<target name="provide-testsuite" depends="init-test, retrieve-xr-testsuite"
description="Download and prepare KoSIT xrechnung-testsuite for testing">
<unzip src="${download.dir}/${xr.testsuite.zip}" dest="${testsuite.instances.dir}">
<patternset>
<include name="**/*.xml" />
</patternset>
<flattenmapper />
</unzip>
</target>
<target name="retrieve-cen-rules"
depends="retrieve-cen-rules-from-master,retrieve-cen-rules-from-release,init" >
<fail message="No cen rule zip files available :(!">
<condition>
<not>
<or>
<resourceexists>
<file file="${download.dir}/master.zip" />
</resourceexists>
<and>
<resourceexists>
<file file="${download.dir}/en16931-cii-${cen.rules.version.download}.zip" />
</resourceexists>
<resourceexists>
<file file="${download.dir}/en16931-ubl-${cen.rules.version.download}.zip" />
</resourceexists>
</and>
</or>
</not>
</condition>
</fail>
<unzip dest="${download.dir}" failonemptyarchive="true">
<!-- If master.zip or the other gets finally extracted depends on download targets -->
<fileset dir="${download.dir}">
<include name="en16931-*-${cen.rules.version.download}.zip" />
<include name="master.zip" />
</fileset>
<regexpmapper from=".*/(schematron/.*\.sch$$)" to="\1" />
</unzip>
<!-- Testing if important files were unzipped -->
<path id="schematron-path">
<fileset dir="${download.dir}" includes="**schematron/**.sch" />
</path>
<fail
message="Could not extract CEN schematron rules file EN16931-UBL-validation.sch does not exist in ${download.dir}">
<condition>
<not>
<available file="EN16931-UBL-validation.sch">
<filepath refid="schematron-path" />
</available>
</not>
</condition>
</fail>
<fail message="Could not extract file EN16931-CII-validation.sch">
<condition>
<not>
<available file="EN16931-CII-validation.sch">
<filepath refid="schematron-path" />
</available>
</not>
</condition>
</fail>
</target>
<target name="retrieve-cen-rules-from-master" depends="init" if="${cen.master.target}"
description="Download CEN business rules (schematron) from master branch to download directory">
<get src="${cen.download.url.master.prefix}/archive/master.zip"
dest="${download.dir}" verbose="true" skipexisting="true"
usetimestamp="true" />
</target>
<target name="retrieve-cen-rules-from-release" depends="init"
unless="${cen.master.target}"
description="Download CEN business rules (schematron) version ${cen.rules.version.download} to download directory">
<!-- download UBL specific rules -->
<get src="${cen.download.url.ubl}" dest="${download.dir}" verbose="true" skipexisting="true"
usetimestamp="true" />
<!-- download CII specific rules -->
<get src="${cen.download.url.cii}" dest="${download.dir}" verbose="true" skipexisting="true"
usetimestamp="true" />
</target>
<target name="retrieve-xrechnung-schematron-from-local-build" depends="init"
if="develop.local.xr.schematron">
<echo message="Loading from file ${xr.schematron.download.url}" />
<get src="${xr.schematron.download.url}" dest="${download.dir}"
verbose="true" skipexisting="false" usetimestamp="false" httpusecaches="false" />
</target>
<target name="retrieve-xrechnung-schematron-from-github-release" depends="init"
unless="develop.local.xr.schematron">
<echo message="Loading from GitHub ${xr.schematron.download.url}" />
<get src="${xr.schematron.download.url}" dest="${download.dir}"
verbose="true" skipexisting="true" usetimestamp="true" />
</target>
<target name="provide-xrechnung-schematron"
depends="init, retrieve-xrechnung-schematron-from-local-build, retrieve-xrechnung-schematron-from-github-release"
description="Retrieve and prepare XRechnung Schemtaron">
<!-- Prepare XRechnung Schematron -->
<unzip src="${download.dir}/${xr.schematron.zip}"
dest="${resource.dir}/xrechnung/${xrechnung.version}/xsl">
<patternset>
<include name="**/XRechnung*.xsl" />
</patternset>
<flattenmapper />
</unzip>
</target>
<target name="retrieve-ubl-schema" depends="init"
description="Download UBL schemas to download directory">
<get src="${ubl.download.url}" dest="${download.dir}" verbose="true" skipexisting="true"
usetimestamp="true" />
</target>
<target name="retrieve-cii-schema" depends="init"
description="Download UN/CEFACT CII schemas to download directory">
<get src="${cii.download.url}" dest="${download.dir}" verbose="true" skipexisting="true"
usetimestamp="true" />
<unzip src="${download.dir}/${cii.schema.zip}" dest="${download.dir}">
<patternset>
<include name="**/D16B*uncoupled.zip" />
</patternset>
<mergemapper to="${cii.schema.uncoupled.zip}" />
</unzip>
</target>
<target name="retrieve-all-schema-rules"
depends="retrieve-ubl-schema,retrieve-cen-rules,provide-xrechnung-schematron,retrieve-cii-schema"
description="Retrieve and prepare all 3rd party XSDs and XSLTs" />
<target name="compile-cen-rules-only" description="Works for zip from master and release zips">
<schematron-compile schematron="${download.dir}/schematron/EN16931-UBL-validation.sch"
insuffix="sch" workdir="${build.dir}/schematron" outdir="${build.dir}" />
<schematron-compile schematron="${download.dir}/schematron/EN16931-CII-validation.sch"
insuffix="sch" workdir="${build.dir}/schematron" outdir="${build.dir}" />
<!-- Creating schematron now using Saxon 9he-->
<!-- according to https://www.saxonica.com/html/documentation/using-xsl/xsltfromant.html-->
<!-- customize CEN schematron rules for UBL -->
<xslt in="${build.dir}/EN16931-UBL-validation.xslt" out="${resource.xsl.cen.ubl}"
style="${src.dir}/remove-dead-apply-templates.xsl">
<classpath location="${lib.dir}/${saxon.jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
<!-- customize CEN schematron rules for CII -->
<xslt in="${build.dir}/EN16931-CII-validation.xslt" out="${resource.xsl.cen.cii}"
style="${src.dir}/remove-dead-apply-templates.xsl">
<classpath location="${lib.dir}/${saxon.jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
</target>
<target name="compile-cen-rules" depends="retrieve-cen-rules,prepare-saxon,compile-cen-rules-only"
description="Works for zip from master and release zips"/>
<target name="compile-scenario" depends="init">
<filter token="build.date" value="${build.date}" />
<filter token="cen.spec.id" value="${cen.spec.id}" />
<filter token="cen.rules.version" value="${cen.rules.version}" />
<filter token="cen.download.url.ubl" value="${cen.download.url.ubl}" />
<filter token="cen.download.url.cii" value="${cen.download.url.cii}" />
<!-- This is actually the schematron part of it -->
<filter token="xrechnung.download.url" value="${xr.schematron.download.url}" />
<filter token="xrechnung.rules.version.full" value="${xr.schematron.version.full}" />
<filter token="xrechnung.rules.version.major.minor" value="${xr.schematron.version.major.minor}" />
<!-- This is actually the specification part of it -->
<filter token="xrechnung.version" value="${xrechnung.version}" />
<filter token="xrechnung.spec.id" value="${xrechnung.spec.id}" />
<filter token="xrechnung.extension.id" value="${xrechnung.extension.id}" />
<filter token="ubl.version" value="${ubl.version}" />
<filter token="ubl.download.url" value="${ubl.download.url}" />
<filter token="cii.version" value="${cii.version}" />
<filter token="cii.download.url" value="${cii.download.url}" />
<copy file="scenarios.xml" todir="${repository.dir}" failonerror="true" filtering="true" />
</target>
<target name="compile"
depends="compile-scenario,retrieve-all-schema-rules,compile-cen-rules,prepare-saxon"
description="Compile XSDs and XSLTs into validation configuration conformat repository directory">
<echo>Compiling Schemas and XSLTs ...</echo>
<copy file="${src.dir}/default-report.xsl" todir="${resource.dir}" />
<copy file="${src.dir}/xrechnung-report.xsl" todir="${resource.dir}" />
<copy file="${src.dir}/report.xsd" todir="${resource.dir}/xsd" />
<unzip src="${download.dir}/${ubl.schema.zip}" dest="${resource.dir}/ubl/2.1/xsd">
<patternset>
<include name="xsdrt/**/*.xsd" />
</patternset>
<cutdirsmapper dirs="1" />
</unzip>
<unzip src="${download.dir}/${cii.schema.uncoupled.zip}" dest="${resource.dir}/cii/16b/xsd">
<patternset>
<include name="**/CrossIndustryInvoice*.xsd" />
</patternset>
<flattenmapper />
</unzip>
</target>
<target name="compile-test-sources">
<filter token="xrechnung.spec.id" value="${xrechnung.spec.id}" />
<copy todir="${test.build.dir}" failonerror="true" filtering="true">
<fileset dir="${test.src.dir}" casesensitive="false">
<include name="**/*.xml" />
</fileset>
</copy>
</target>
<target name="init-test" depends="init, compile, compile-scenario, compile-test-sources"
description="Initializes test directory structure">
<mkdir dir="${test.build.dir}" />
<!-- XSDs for validating e.g. scenario.xml and the output report -->
<mkdir dir="${resource.dir}/xsd" />
<mkdir dir="${testsuite.instances.dir}" />
<!-- customize scenarios.xml for testing purpose -->
<xslt in="${repository.dir}/scenarios.xml" out="${test.build.dir}/scenarios.xml"
style="${src.dir}/create-test-scenario.xsl">
<classpath location="${lib.dir}/${saxon.jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
</target>
<target name="test-validator-assertions"
depends="init-test,provide-validator,test-validator-assertions-only,test-validator-report-with-schema-only"
description="Test XRechnung Configuration">
<echo message="Testing with full build chain." />
</target>
<target name="test-validator-report-with-schema-only">
<echo>Schema validating reports against ${reports.schema.dir}/report.xsd ...</echo>
<schemavalidate fullchecking="yes" failonerror="yes">
<schema namespace="http://www.xoev.de/de/validator/varl/1"
file="${reports.schema.dir}/report.xsd" />
<schema namespace="http://www.xoev.de/de/validator/framework/1/scenarios"
file="${reports.schema.dir}/scenarios.xsd" />
<fileset dir="${reports.dir}" includes="*-report.xml" />
</schemavalidate>
<echo>Schematron validating reports ...</echo>
<xslt style="${src.dir}/report.sch.xsl" includes="${reports.dir}/*.xml" destdir="${reports.dir}">
<classpath location="${lib.dir}/${saxon.jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
</xslt>
</target>
<target name="test-validator-assertions-only" description="Only test XRechnung Configuration"
unless="test.skip">
<echo>Creating validation reports with ${lib.dir}/${validator.jar}.</echo>
<java jar="${lib.dir}/${validator.jar}" failonerror="yes" fork="yes" dir="${build.dir}">
<arg value="-s" />
<arg value="${test.build.dir}/scenarios.xml" />
<arg value="-r" />
<arg value="${build.dir}" />
<arg value="--html" />
<arg value="-l" />
<arg value="INFO" />
<arg value="--check-assertions" />
<arg value="${test.src.dir}/assertions.xml" />
<arg value="-o" />
<arg value="${reports.dir}" />
<arg value="${test.docs.dir}/instances" />
</java>
</target>
<!-- TODO name could be improved -->
<target name="create-validator-reports-from-testsuite"
depends="init-test, provide-validator, provide-testsuite"
description="Only test XRechnung Configuration" unless="test.skip">
<fail unless="testsuite.instances.dir"
message="Property testsuite.instances.dir must exist for this target to work" />
<echo>Creating validation reports with ${lib.dir}/${validator.jar} for ${testsuite.instances.dir}.</echo>
<java jar="${lib.dir}/${validator.jar}" failonerror="true" fork="true" dir="${build.dir}">
<arg value="-s" />
<arg value="scenarios.xml" />
<arg value="-r" />
<arg value="${build.dir}" />
<arg value="--html" />
<arg value="-o" />
<arg value="${reports.dir}/testsuite" />
<arg value="${testsuite.instances.dir}" />
</java>
</target>
<target name="check-custom-tests-folder-is-empty">
<fileset dir="${test.docs.custom.dir}" id="custom"/>
<pathconvert refid="custom" property="fileset.nonempty" setonempty="false"/>
</target>
<target name="create-validator-reports-from-custom-tests" depends="init-test, provide-validator, check-custom-tests-folder-is-empty"
description="Validate custom test" unless="test.skip" if="fileset.nonempty">
<fail unless="test.docs.custom.dir"
message="Property test.docs.custom.dir must exist for this target to work"/>
<echo>Creating validation reports with ${lib.dir}/${validator.jar} for
${test.docs.custom.dir}.</echo>
<java jar="${lib.dir}/${validator.jar}" failonerror="true" fork="true" dir="${build.dir}">
<arg value="-s"/>
<arg value="scenarios.xml"/>
<arg value="-r"/>
<arg value="${build.dir}"/>
<arg value="--html"/>
<arg value="-o"/>
<arg value="${reports.dir}/custom-tests"/>
<arg value="${test.docs.custom.dir}"/>
</java>
</target>
<target name="retrieve-xmute" depends="init">
<fail unless="xmute.download.url.prefix"
message="Property xmute.download.url.prefix must exist for this target to work" />
<property name="xmute.version.full" value="0.5" />
<property name="xmute.jar" value="xml-mutate.jar" />
<get src="${xmute.download.url.prefix}/target/xml-mutate-${xmute.version.full}.jar"
dest="${lib.dir}/${xmute.jar}" verbose="true" skipexisting="false" usetimestamp="true" />
</target>
<target name="test-cen-expected-behaviour" depends="compile, init-test, retrieve-xmute"
description="Test Schematron Rules with XML-Mutate" if="xmute.download.url.prefix">
<echo>Generate and test instances with expected behaviour ...</echo>
<java jar="${lib.dir}/${xmute.jar}" failonerror="true" fork="true" dir="${basedir}">
<arg value="--schematron" />
<arg value="xrubl=${resource.xsl.xr.ubl}" />
<arg value="--schematron" />
<arg value="cenubl=${resource.xsl.cen.ubl}" />
<arg value="--schematron" />
<arg value="cencii=${resource.xsl.cen.cii}" />
<arg value="--target ${test.docs.dir}/generated" />
<arg value="${test.docs.cen.unit.dir}" />
</java>
</target>
<target name="test-integration" depends="init-test, provide-validator, provide-testsuite, test-cen-expected-behaviour, test-integration-only"
description="Integration testing result of XRechnung Configuration"></target>
<target name="test-cen-unexpected-behaviour" depends="compile, init-test, retrieve-xmute"
description="Test for unexpected behaviour in CEN Schematron Rules">
<echo>Generate and test instances with unexpected behaviour ...</echo>
<java jar="${lib.dir}/${xmute.jar}" failonerror="true" fork="true" dir="${basedir}">
<arg value="--schematron" />
<arg value="xrubl=${resource.xsl.xr.ubl}" />
<arg value="--schematron" />
<arg value="cenubl=${resource.xsl.cen.ubl}" />
<arg value="--schematron" />
<arg value="cencii=${resource.xsl.cen.cii}" />
<arg value="--target ${test.docs.dir}/generated" />
<arg value="${test.docs.cen.unit.unexpected.dir}" />
</java>
</target>
<target name="test-integration-only" description="Nothing but integration testing">
<echo message="Compiling instances for integration tests"/>
<!-- Requires output of XML Mutate -->
<copy todir="${test.docs.integration.dir}" verbose="true">
<fileset dir="${test.docs.cen.unit.dir}">
<include name="cii-br-s-08-rounding-rule.xml"/>
<include name="ubl-br-dex-2-false-negative.xml"/>
<include name="cii-bt-20-cardinality-check.xml"/>
<include name="cii-bt-20-cardinality-check-2.xml"/>
<include name="cii-cii-sr-454-negative-test.xml"/>
<!-- Local files - not in repository -->
<include name="XRechnung-CEFACT*.xml"/>
</fileset>
<fileset dir="${test.src.dir}/integration"></fileset>
</copy>
<echo>Creating validation reports with ${lib.dir}/${validator.jar} for ${test.docs.integration.dir}</echo>
<java jar="${lib.dir}/${validator.jar}" failonerror="true" fork="true" dir="${build.dir}">
<arg value="-l" />
<arg value="DEBUG" />
<arg value="-s" />
<arg value="scenarios.xml" />
<arg value="-r" />
<arg value="${build.dir}" />
<arg value="--check-assertions" />
<arg value="${test.docs.dir}/assertions-integration-testing.xml" />
<arg value="--html" />
<arg value="-o" />
<arg value="${reports.dir}/integration" />
<arg value="${test.docs.integration.dir}" />
</java>
</target>
<target name="test"
depends="init-test, test-validator-assertions,create-validator-reports-from-testsuite, test-cen-expected-behaviour, test-integration, create-validator-reports-from-custom-tests">
<echo message="Testing all" />
</target>
<target name="dist-only" description="Generate the distribution without testing">
<copy todir="${build.dir}">
<fileset dir="${basedir}">
<include name="README.md" />
<include name="CHANGELOG.md" />
</fileset>
</copy>
<zip destfile="${dist.dir}/${dist.name}" basedir="${build.dir}"
excludes="download/**,test/**,schematron/**,reports/**" />
</target>
<target name="dist" depends="compile,test, dist-only" description="Generate the distribution"> </target>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build.dir}" verbose="true" includeEmptyDirs="true" />
<delete dir="${dist.dir}" />
<delete dir="${lib.dir}" />
<delete dir="${reports.dir}" />
</target>
</project>