forked from itplr-kosit/xrechnung-visualization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
201 lines (196 loc) · 11.4 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
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="xrechnung-visualization" default="test">
<!-- project directory structure -->
<property name="dist.dir" location="${basedir}/dist" />
<property name="lib.dir" location="${basedir}/lib" />
<property name="build.dir" location="${basedir}/build" />
<property name="src.dir" location="${basedir}/src" />
<property name="download.dir" location="${build.dir}/download" />
<property name="saxon.jar" value="saxon9he.jar" />
<!-- Test resources -->
<property name="validator.jar" value="validationtool-1.0.1-standalone.jar" />
<property name="github.group.url" value="https://github.com/itplr-kosit"/>
<property name="xrechnung.version.full" value="1.2.0" />
<property name="validator.download.url"
value="${github.group.url}/validationtool/releases/download/validationtool-1_0_1/validationtool-dist-1.0.1-standalone.zip"/>
<property name="validator.config.proj.name" value="validator-configuration-xrechnung"/>
<property name="validator.config.download.url"
value="${github.group.url}/${validator.config.proj.name}/releases/download/release-2018-12-19/${validator.config.proj.name}_${xrechnung.version.full}_2018-12-19.zip"/>
<property name="validator.config.release.version" value="release-2018-12-19" />
<property name="validator.config.zip"
value="validator-configuration-xrechnung_1.2.0_2018-12-19.zip" />
<property name="validator.repository.dir" location="${build.dir}/xrechnung-configuration-repository" />
<!-- vnu html validator -->
<property name="vnu.jar" value="vnu.jar" />
<property name="vnu.version" value="18.11.5" />
<property name="vnu.zip" value="${vnu.jar}_${vnu.version}.zip" />
<property name="vnu.download.url" value="https://github.com/validator/validator/releases/download/${vnu.version}/${vnu.zip}" />
<property name="xr.testsuite.docs.download.url.base" value="https://raw.githubusercontent.com/itplr-kosit/xrechnung-testsuite/master/instances" />
<property name="test.src.dir" location="${src.dir}/test" />
<property name="test.build.dir" location="${build.dir}/test" />
<property name="test.docs.dir" location="${test.build.dir}/instances" />
<property name="test.transformed.dir" location="${test.build.dir}/transformed" />
<property name="test.transformed.html.dir" location="${test.build.dir}/html" />
<property name="test.reports.dir" location="${test.build.dir}/reports" />
<property name="xrechnung.xsd.ns" value="urn:ce.eu:en16931:2017:xoev-de:kosit:standard:xrechnung-1" />
<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="${test.docs.dir}" />
<mkdir dir="${test.transformed.dir}" />
<mkdir dir="${test.transformed.html.dir}" />
<mkdir dir="${test.reports.dir}" />
<mkdir dir="${validator.repository.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/9.8/SaxonHE9-8-0-8J.zip/download" dest="${download.dir}/SaxonHE9-8-0-8J.zip" verbose="true" skipexisting="true" usetimestamp="true" />
<fail unless="saxon.jar" message="Provide a name for the extracted saxon jar" />
<unzip src="${download.dir}/SaxonHE9-8-0-8J.zip" dest="${lib.dir}">
<patternset>
<include name="**/${saxon.jar}" />
</patternset>
<flattenmapper />
</unzip>
</target>
<target name="prepare-validationtool" depends="init" description="Download KoSIT validation tool and add jar to library directory">
<get src="https://github.com/itplr-kosit/validator/releases/download/validationtool-1_0_1/validationtool-dist-1.0.1-standalone.zip" dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true" />
<!-- Cause unzip task does not error on missing dest directory -->
<fail message="Lib directory ${lib.dir} does not exist!">
<condition>
<not>
<available file="${lib.dir}" />
</not>
</condition>
</fail>
<fail unless="validator.jar" message="Need to specify property with name 'validator.jar'" />
<unzip src="${download.dir}/validationtool-dist-1.0.1-standalone.zip" dest="${lib.dir}">
<patternset>
<include name="**/${validator.jar}" />
</patternset>
<flattenmapper />
</unzip>
</target>
<target name="prepare-vnu" depends="init" description="Download vNU">
<get src="${vnu.download.url}" dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true" />
<!-- Cause unzip task does not error on missing dest directory -->
<fail message="Lib directory ${lib.dir} does not exist!">
<condition>
<not>
<available file="${lib.dir}" />
</not>
</condition>
</fail>
<fail unless="vnu.jar" message="Need to specify property with name 'vnu.jar'" />
<unzip src="${download.dir}/${vnu.zip}" dest="${lib.dir}">
<patternset>
<include name="**/${vnu.jar}" />
</patternset>
<flattenmapper />
</unzip>
</target>
<target name="prepare-validator-configuration" depends="prepare-validationtool">
<get src="${validator.config.download.url}" dest="${download.dir}" verbose="true" skipexisting="true" usetimestamp="true" />
<unzip src="${download.dir}/${validator.config.zip}" dest="${validator.repository.dir}" />
</target>
<target name="prepare-testsuite" depends="init">
<copy todir="${test.build.dir}" verbose="true">
<fileset dir="${test.src.dir}" includes="**/*.xml" />
</copy>
<loadfile property="urls" srcFile="${test.src.dir}/testsuite-instances.txt">
<filterchain>
<prefixlines prefix="${xr.testsuite.docs.download.url.base}/" />
</filterchain>
</loadfile>
<echo message="${urls}" file="${test.build.dir}/testsuite-instance-urls.txt" />
<get dest="${test.docs.dir}" verbose="true" skipexisting="true" usetimestamp="true">
<resourcelist>
<file name="${test.build.dir}/testsuite-instance-urls.txt" />
</resourcelist>
</get>
</target>
<target name="transform-ubl-invoice-to-xr" depends="prepare-testsuite, prepare-saxon">
<xslt basedir="${test.docs.dir}" destdir="${test.transformed.dir}" style="${src.dir}/xsl/ubl-invoice-xr.xsl" includes="**/*ubl.xml,**/maxRechnung.xml">
<classpath location="${lib.dir}/${saxon.jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
<mapper type="glob" from="*.xml" to="*-xr.xml" />
</xslt>
</target>
<target name="transform-ubl-creditnote-to-xr" depends="prepare-testsuite, prepare-saxon">
<xslt basedir="${test.docs.dir}" destdir="${test.transformed.dir}" style="${src.dir}/xsl/ubl-creditnote-xr.xsl" includes="**/maxRechnung-creditnote.xml">
<classpath location="${lib.dir}/${saxon.jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
<mapper type="glob" from="*.xml" to="*-xr.xml" />
</xslt>
</target>
<target name="transform-cii-to-xr" depends="prepare-testsuite, prepare-saxon">
<xslt basedir="${test.docs.dir}" destdir="${test.transformed.dir}" style="${src.dir}/xsl/cii-xr.xsl" includes="**/*uncefact.xml">
<classpath location="${lib.dir}/${saxon.jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
<mapper type="glob" from="*.xml" to="*-xr.xml" />
</xslt>
</target>
<target name="transform-ubl-to-xr" description="Transforms UBl Invoice and
CreditNote to XRechnung Semantic Model" depends="transform-ubl-invoice-to-xr, transform-ubl-creditnote-to-xr">
<!-- Just container for both transformations -->
</target>
<target name="transform-xr-to-html" depends="transform-ubl-to-xr">
<xslt basedir="${test.transformed.dir}" destdir="${test.transformed.html.dir}" style="${src.dir}/xsl/xrechnung-html.xsl" includes="**/*.xml">
<classpath location="${lib.dir}/${saxon.jar}" />
<factory name="net.sf.saxon.TransformerFactoryImpl" />
<mapper type="glob" from="*.xml" to="*.html" />
</xslt>
</target>
<target name="test-testsuite" depends="prepare-validationtool,prepare-validator-configuration, prepare-testsuite" description="Testsuite validation with Validator XRechnung Configuration">
<echo>Creating validation reports ...</echo>
<java jar="${lib.dir}/${validator.jar}" failonerror="yes" fork="yes" dir="${basedir}">
<arg value="-s" />
<arg value="${validator.repository.dir}/scenarios.xml" />
<arg value="-r" />
<arg value="${validator.repository.dir}" />
<arg value="-h" />
<arg value="-o" />
<arg value="${test.reports.dir}" />
<arg value="${test.docs.dir}/*.xml" />
</java>
</target>
<target name="test-html" depends="prepare-vnu,transform-xr-to-html" description="Tests HTML generation with vNU b W3C">
<echo>Validating HTML ...</echo>
<java jar="${lib.dir}/${vnu.jar}" failonerror="false" fork="yes" dir="${basedir}" logerror="true">
<arg value="--skip-non-html" />
<arg value="${test.transformed.html.dir}" />
</java>
</target>
<target name="test-xr-transformation" depends="transform-ubl-to-xr">
<schemavalidate fullchecking="yes" failonerror="yes" warn="true" lenient="false">
<schema namespace="${xrechnung.xsd.ns}" file="${src.dir}/xsd/xrechnung-semantic-model.xsd" />
<fileset dir="${test.transformed.dir}" includes="*.xml" />
</schemavalidate>
</target>
<!-- Just testing that task schemavalidate works cause it does not emit any
message on success -->
<target name="direct-test-transformation">
<schemavalidate fullchecking="yes" failonerror="yes" warn="true" lenient="false">
<fileset dir="${test.transformed.dir}" includes="*.xml" />
<schema namespace="${xrechnung.xsd.ns}" file="${src.dir}/xsd/xrechnung-semantic-model.xsd" />
</schemavalidate>
</target>
<target name="test" depends="test-testsuite, test-xr-transformation, test-html" description="Validates source UBL or CII XML against XRechnung,
transforms to XR Sem Model and schema validates results" />
<target name="dist" depends="test">
<zip
destfile="${dist.dir}/xrechnung-${xrechnung.version.full}-${ant.project.name}-${build.date}.zip" basedir="${src.dir}" excludes="download/**,test/**" />
</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>