-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.xml
319 lines (261 loc) · 11.9 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
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="xrechnung-testsuite" default="compile-test">
<property name="dist.dir" location="${basedir}/dist" />
<property name="lib.dir" location="${basedir}/lib" />
<property name="src.dir" location="${basedir}/src" />
<property name="src.doc.dir" location="${basedir}/src/doc" />
<property name="instance.dir" location="${basedir}/instances" />
<property name="build.dir" location="${basedir}/build" />
<property name="download.dir" location="${build.dir}/download" />
<!-- the source of test instances -->
<property name="test.src.dir" location="${src.dir}/test" />
<property name="test.src.technical.dir"
location="${test.src.dir}/technical-cases" />
<property name="test.src.business.dir"
location="${test.src.dir}/business-cases" />
<!-- test instances in the build directory-->
<property name="test.build.dir" location="${build.dir}/instances" />
<property name="test.build.technical.dir"
location="${test.build.dir}/technical-cases" />
<property name="test.build.standard.dir"
location="${test.build.dir}/standard" />
<property name="test.build.extension.dir"
location="${test.build.dir}/extension" />
<property name="test.build.generated.dir"
location="${test.build.dir}/generated" />
<property name="reports.dir" location="${build.dir}/reports" />
<property name="testsuite.version.date" value="2025-01-31-SNAPSHOT" />
<property name="_xrechnung.version.majorminor" value="3.0" />
<property name="xrechnung.version.full" value="${_xrechnung.version.majorminor}.2" />
<!-- For cii2ubl -->
<property name="_cii2ubl.baseurl" value="https://github.com/phax/en16931-cii2ubl/releases/download/" />
<property name="_cii2ubl.version" value="2.2.4" />
<property name="cii2ubl.download.url" value="${_cii2ubl.baseurl}en16931-cii2ubl-parent-pom-${_cii2ubl.version}/en16931-cii2ubl-cli-${_cii2ubl.version}-shaded.jar" />
<property name="cii2ubl.download.skipexisting" value="true" />
<property name="cii2ubl.jar" value="cii2ubl-${_cii2ubl.version}.jar" />
<property name="cii2ubl.customizationid" value="urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_${_xrechnung.version.majorminor}" />
<property name="cii2ubl.local.enabled" value="false" />
<property name="cii2ubl.local.url" value="define in development.build.properties" />
<!-- this must be a direct absolute path -->
<property name="validator.configuration.resources.dir" value="${validator.configuration.project.dir}/build/resources"/>
<property name="validator.dir" value="${validator.configuration.project.dir}/lib"/>
<property name="validator.version.full" value="1.5.0"/>
<property name="validator.jar" value="validationtool-${validator.version.full}-standalone.jar"/>
<property name="dist.name"
value="xrechnung-${xrechnung.version.full}-testsuite-${testsuite.version.date}" />
<target name="init"
description="Initializes build directory structure and ISO timestamp">
<!-- 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="${dist.dir}" />
<mkdir dir="${lib.dir}" />
<mkdir dir="${reports.dir}" />
</target>
<target name="provide-validator-configuration">
<fail unless="validator.configuration.project.dir"
message="Set validator.configuration.project.dir property e.g. at command line" />
<echo message="Checking ${validator.configuration.resources.dir}" />
<fail unless="validator.configuration.resources.dir"
message="Set validator.configuration.resources.dir in properties file" />
<fail
message="Directory does not exist: ${validator.configuration.resources.dir}">
<condition>
<not>
<available file="${validator.configuration.resources.dir}" type="dir"
/>
</not>
</condition>
</fail>
<fail message="Validator does not exist: ${validator.jar}">
<condition>
<not>
<available file="${validator.dir}/${validator.jar}" type="file" />
</not>
</condition>
</fail>
</target>
<target name="compile-test" depends="init"
description="Compiling test instances from sources">
<!-- Currently we just copy, but later we will transform etc. before testing -->
<copy todir="${test.build.dir}">
<fileset dir="${test.src.business.dir}" />
</copy>
<copy todir="${test.build.technical.dir}">
<fileset dir="${test.src.technical.dir}" >
<exclude name="00.*.xml" />
</fileset>
</copy>
</target>
<target name="compile-doc" depends="init"
description="Compiling documentation from sources">
<!-- Currently we just copy, but later we will transform etc. before testing -->
<copy todir="${build.dir}" verbose="true">
<fileset dir="${src.doc.dir}" />
</copy>
</target>
<target name="compile" depends="compile-test, compile-doc"
description="Compiling Testsuite from sources">
</target>
<target name="validator-standard-business-case-test"
depends="compile-test, provide-validator-configuration"
description="Testsuite business case validation"
>
<echo>Creating validation reports for standard business cases ...</echo>
<java jar="${validator.dir}/${validator.jar}" failonerror="yes" fork="yes"
dir="${basedir}">
<arg value="-s" />
<arg value="${validator.configuration.project.dir}/build/scenarios.xml" />
<arg value="-r" />
<arg value="${validator.configuration.project.dir}/build" />
<arg value="-h" />
<arg value="-o" />
<arg value="${reports.dir}" />
<arg value="${test.build.standard.dir}" />
</java>
</target>
<target name="validator-extension-business-case-test"
depends="compile-test, provide-validator-configuration"
description="Testsuite business case validation"
>
<echo>Creating validation reports for extension business cases ...</echo>
<java jar="${validator.dir}/${validator.jar}" failonerror="yes" fork="yes"
dir="${basedir}">
<arg value="-s" />
<arg value="${validator.configuration.project.dir}/build/scenarios.xml" />
<arg value="-r" />
<arg value="${validator.configuration.project.dir}/build" />
<arg value="-h" />
<arg value="-o" />
<arg value="${reports.dir}" />
<arg value="${test.build.extension.dir}" />
</java>
</target>
<target name="validator-technical-test"
depends="compile-test, provide-validator-configuration"
description="Testsuite technical validation with Validator XRechnung Configuration"
>
<echo>Creating validation reports for technical cases ...</echo>
<java jar="${validator.dir}/${validator.jar}" failonerror="yes" fork="yes"
dir="${basedir}">
<arg value="-s" />
<arg value="${validator.configuration.project.dir}/build/scenarios.xml" />
<arg value="-r" />
<arg value="${validator.configuration.project.dir}/build" />
<arg value="-h" />
<arg value="-o" />
<arg value="${reports.dir}" />
<arg value="${test.build.technical.dir}" />
</java>
</target>
<target name="validator-generated-business-case-test"
depends="cii2ubl, provide-validator-configuration"
description="Testsuite generated business case validation"
>
<echo>Creating validation reports for generated business cases ...</echo>
<java jar="${validator.dir}/${validator.jar}" failonerror="yes" fork="yes"
dir="${basedir}">
<arg value="-s" />
<arg value="${validator.configuration.project.dir}/build/scenarios.xml" />
<arg value="-r" />
<arg value="${validator.configuration.project.dir}/build" />
<arg value="-h" />
<arg value="-o" />
<arg value="${reports.dir}" />
<arg value="${test.build.generated.dir}/business-cases" />
</java>
</target>
<target name="validator-generated-technical-case-test"
depends="cii2ubl, provide-validator-configuration"
description="Testsuite generated technical case validation"
>
<echo>Creating validation reports for generated business cases ...</echo>
<java jar="${validator.dir}/${validator.jar}" failonerror="yes" fork="yes"
dir="${basedir}">
<arg value="-s" />
<arg value="${validator.configuration.project.dir}/build/scenarios.xml" />
<arg value="-r" />
<arg value="${validator.configuration.project.dir}/build" />
<arg value="-h" />
<arg value="-o" />
<arg value="${reports.dir}" />
<arg value="${test.build.generated.dir}/technical-cases" />
</java>
</target>
<target name="validator-test"
depends="validator-extension-business-case-test,validator-standard-business-case-test,validator-technical-test, validator-generated-test">
</target>
<target name="retrieve-cii2ubl-remote" depends="init" unless="${cii2ubl.local.enabled}">
<echo>Downloading remote CII2UBL</echo>
<get src="${cii2ubl.download.url}"
dest="${lib.dir}/${cii2ubl.jar}"
verbose="true"
skipexisting="${cii2ubl.download.skipexisting}"
usetimestamp="true" />
</target>
<target name="retrieve-cii2ubl-local" depends="init" if="${cii2ubl.local.enabled}">
<echo>Using local CII2UBL</echo>
<copy file="${cii2ubl.local.url}" tofile="${lib.dir}/${cii2ubl.jar}"/>
</target>
<macrodef name="execute-cii2ubl" description="Execute cii2ubl on the provided parameters">
<attribute name="srcdir" description="Directory with the CII files" />
<attribute name="dstdir" default="${test.build.generated.dir}" />
<attribute name="filemask" default="*_uncefact.xml" />
<sequential>
<echo>Running CII2UBL in @{srcdir}</echo>
<java jar="${lib.dir}/${cii2ubl.jar}" failonerror="true" fork="true" dir="${basedir}">
<arg value="--mode" />
<arg value="AUTOMATIC" />
<arg value="--ubl-customizationid" />
<arg value="${cii2ubl.customizationid}" />
<arg value="--ubl-defaultorderrefid" />
<arg value="'-'" />
<arg value="--target" />
<arg value="@{dstdir}" />
<arg value="--output-suffix" />
<arg value="_ubl_generated" />
<arg value="@{srcdir}/@{filemask}" />
</java>
</sequential>
</macrodef>
<target name="cii2ubl" depends="retrieve-cii2ubl-remote, retrieve-cii2ubl-local">
<execute-cii2ubl srcdir="${test.src.business.dir}/standard" dstdir="${test.build.generated.dir}/business-cases" />
<execute-cii2ubl srcdir="${test.src.technical.dir}" dstdir="${test.build.generated.dir}/technical-cases" />
</target>
<target name="validator-generated-test"
depends="validator-generated-business-case-test, validator-generated-technical-case-test">
</target>
<target name="test" depends="compile-test,validator-test"
description="Perform all tests">
<echo message="Executing all tests" />
</target>
<target name="dist-only" description="Create distribution zip for release">
<zip destfile="${dist.dir}/${dist.name}.zip">
<zipfileset dir="${test.build.dir}" includes="extension/**,standard/**,technical-cases/**" prefix="instances" />
<zipfileset dir="doc" prefix="doc"/>
<!-- Project documents-->
<fileset dir="${basedir}">
<include name="README.md" />
<include name="CHANGELOG.md" />
</fileset>
<!-- Content documents-->
<fileset dir="${build.dir}">
<include name="test-overview.md" />
</fileset>
</zip>
</target>
<target name="dist" depends="test, compile-doc, dist-only"
description="Create distribution zip for release">
<echo message="Created distribution" />
</target>
<target name="clean">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build.dir}" verbose="true" includeEmptyDirs="true" />
<delete dir="${dist.dir}" />
</target>
</project>