/[volute]/trunk/projects/dm/vo-dml/tools/build.xml
ViewVC logotype

Contents of /trunk/projects/dm/vo-dml/tools/build.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4266 - (show annotations)
Tue Sep 12 16:26:06 2017 UTC (3 years, 4 months ago) by mdittmar
File MIME type: text/xml
File size: 20795 byte(s)
syncing 4257 and 4260
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE project [
4 <!ENTITY buildJava SYSTEM "./build_java.xml">
5 <!ENTITY buildJalopy SYSTEM "./build_jalopy.xml">
6 ]>
7
8 <project name="VO-DML-builder" default="run_vo-dml" basedir=".">
9
10 <description>
11 This build file can be considered as the transformer tool for any data model in VO-DML format,
12 the official IVOA VO-DML data model language.
13 Such files can be generated from an xmi file formatted with MagicDraw CE 12.1. [TODO add more info about this].
14 But can also be written by hand or generated any other way.
15 Further targets exist for
16 - updating utype-s of a VO-DML file with a version conforming to the UTYPEs grammar
17 [TODO define this explicitly].
18 - validating a vo-dml file.
19 - generating HTML documentation with UTYPE assignments (html)
20 - generating GraphViz file + PNG image +cmap for use in generated HTML file.
21
22 Note: the targets starting with run_ generally require ant-contrib to be available.
23 See http://ant-contrib.sourceforge.net/
24 This will allow one to run targets for multiple models in one go.
25 Otherwise the targets without the run_ must be used.
26 TBD do a check if ant-contrib exists and
27
28
29 TODO: add other generation targets, e.g. XML schema, TAP, DDL, Java.
30 In VO-URP we had XSLT for that as well,
31 we may decide for alternative generation mechanisms here.
32
33 Authors : lemson@mpa-garching.mpg.de, [Laurent Bourges]
34
35 Version : 2012-11-23
36 </description>
37
38
39 <property file="build.properties" />
40 <property file="${model}/vo-dml.properties" />
41 <property name="ant.contrib.jar" value="./libs/ant-contrib-0.6.jar"/>
42
43
44 <!-- define XSLT2 task -->
45 <presetdef name="xslt2">
46 <!-- The processor=SaxonLiaison setting causes our custom XSLTLiaison class to be used. -->
47 <!-- This works around bug #41314: http://issues.apache.org/bugzilla/show_bug.cgi?id=41314 -->
48 <xslt force="true" classpath="./libs/saxon9.jar:./libs/ant-trax.jar:./libs" processor="SaxonLiaison">
49 <outputproperty name="{http://saxon.sf.net/}indent-spaces" value="2" />
50 </xslt>
51 </presetdef>
52
53 <target name="set-ant-contrib" if="ant.contrib.jar">
54 <taskdef resource="net/sf/antcontrib/antlib.xml">
55 <classpath>
56 <pathelement location="${ant.contrib.jar}" />
57 </classpath>
58 </taskdef>
59 </target>
60
61 <!-- allow use of schematron to validate vo-dml -->
62 <!--
63 <taskdef name="schematron" classname="com.schematron.ant.SchematronTask" classpath="./libs/ant-schematron-2010-04-14.jar" />
64 -->
65 <!-- set global properties for this build -->
66
67 <!-- get build properties (model dependent) -->
68 <tstamp>
69 <format property="build.date" pattern="yyyy-MM-dd HH:mm:ss" />
70 </tstamp>
71
72 <!-- unused/obsolete ???
73 <property name="source_checked" value="${dm.filename.prefix}_CHECK.xml" />
74 <property name="paths.target" value="${dm.filename.prefix}.paths.html" />
75 <property name="paths.target.xml" value="${dm.filename.prefix}.paths.xml" />
76 <property name="pojo.target" value="${dm.filename.prefix}.pojo.xml" />
77 <property name="uml" location="./uml" />
78 <property name="build" location="./build"/>
79 <property name="build.jaxb" location="${build}/jaxb" />
80 <property name="build.jaxb.jar" value="vo-dml.jaxb.jar" />
81 <property name="build.src" location="${build}/src" />
82 <property name="build.src.jar" value="vo-dml.src.jar" />
83 <property name="build.gen" location="${build}/gen" />
84 <property name="build.gen.jar" value="vo-dml.models.jar" />
85 -->
86
87 <!-- locations of support code/modules -->
88 <property name="libs" location="./libs" />
89 <property name="xsd" location="../xsd" />
90 <property name="xslt" location="./xslt" />
91
92 <!-- vo-dml generation properties -->
93 <property name="vo-dml.dir" value="${model}/xml" />
94 <property name="vo-dml.source" value="${dm.filename.prefix}.vo-dml.xml" />
95
96 <property name="html.dir" value="${model}" />
97 <property name="html.target" value="${dm.filename.prefix}.html" />
98 <property name="graphviz.gvd" value="${dm.filename.prefix}.gvd" />
99 <property name="graphviz.png" value="${dm.filename.prefix}.png" />
100 <property name="graphviz.map" value="${dm.filename.prefix}.cmap" />
101 <property name="graphviz.map.placeholder" value="___GRAPHVIZ_MAP___" />
102
103
104 <!-- java generation properties -->
105 <property name="rdf.target" value="${dm.filename.prefix}.ttl"/>
106 <property name="java.gen" location="./java/gen" />
107 <property name="sources.gen" location="${java.gen}" />
108 <property name="sources" location="./java/src" />
109 <property name="jaxb" location="./java/jaxb" />
110 <property name="jaxb.preserve" location="./java/jaxb-preserve" />
111 <property name="jaxb.libs" location="${libs}/jaxb" />
112
113 <!-- schema generation properties -->
114 <property name="xsd.gen" location="./models-xsd" />
115
116
117 <fileset id="jarfiles" dir="${libs}">
118 <!-- eclipselink (2.2.0) JPA 2.0 reference implementation -->
119 <include name="eclipselink.jar" />
120 <include name="kxml2-2.3.0.jar" />
121 <include name="mongo-java-driver-2.9.3.jar" />
122 </fileset>
123
124 <!-- target about : -->
125 <target name="about" depends="init" description="show information for public targets">
126 <echo>available ant targets : </echo>
127 <echo>-------------------------------------------------------------------------------</echo>
128 <echo> - updateSpec : make all transformations (uml -> metaModel -> others) </echo>
129 <echo> required for the specification </echo>
130 <echo>-------------------------------------------------------------------------------</echo>
131 </target>
132
133 <!-- target init : timestamp -->
134 <target name="init">
135 <echo>-------------------------------------------------------------------------------</echo>
136 <echo> project name : ${dm.filename.prefix} </echo>
137 <echo>-------------------------------------------------------------------------------</echo>
138 </target>
139
140 <!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
141 vo-dml generation
142 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
143
144 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
145 <!-- Target: run_vo-dml -->
146 <!-- Description: Run xmi2vo-dml, validate_vo-dml, vo-dml2html in sequence -->
147 <!-- on each target model -->
148 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
149 <target name="run_vo-dml" depends="set-ant-contrib" description="generate VO-DML/XML, validate it and generate HTML for all generated model, requires ant-contrib">
150 <fail unless="models" message="Must define property 'models' in build.properties before running run_vo-dml_all target !" />
151 <for list="${models}" param="model">
152 <sequential>
153 <ant target="run_xmi2vo-dml" inheritAll="true"/>
154 <ant target="run_validate_vo-dml" inheritAll="true"/>
155 <ant target="run_vo-dml2html" inheritAll="true"/>
156 </sequential>
157 </for>
158 </target>
159
160 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
161 <!-- Target: run_xmi2vo-dml -->
162 <!-- Description: Translate model(s) from XMI to vo-dml/xml -->
163 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
164 <target name="run_xmi2vo-dml" depends="set-ant-contrib"
165 description="generate VO-DML/XML from XMI for all indicated models, requires ant-contrib">
166 <fail unless="models" message="Must define property 'models' in build.properties before running run_vo-dml_all target !" />
167 <for list="${models}" param="model">
168 <sequential>
169 <ant target="xmi2vo-dml" inheritall="false">
170 <property name="model" value="@{model}" />
171 </ant>
172 </sequential>
173 </for>
174 </target>
175
176 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
177 <!-- Target: run_validate_vo-dml -->
178 <!-- Description: validate vo-dml/xml model(s) -->
179 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
180 <target name="run_validate_vo-dml" depends="set-ant-contrib"
181 description="validate all VO-MDL/XML models in the list of input models">
182 <fail unless="ant.contrib.jar" message="ant.contrib.jar is not specified, use validate_vo-dml instead with single model in input variable"/>
183 <fail unless="models" message="Must define property 'models' in build.properties before running run_vo-dml_all target !" />
184 <for list="${models}" param="model">
185 <sequential>
186 <ant target="validate_vo-dml" inheritall="false">
187 <property name="model" value="@{model}"/>
188 </ant>
189 </sequential>
190 </for>
191 </target>
192
193 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
194 <!-- Target: run_vo-dml2html -->
195 <!-- Description: generate HTML documentation for model(s) -->
196 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
197 <target name="run_vo-dml2html" depends="set-ant-contrib"
198 description="generate HTML documentation for all indicated models, requires ant-contrib">
199 <fail unless="models" message="Must define property 'models' in build.properties before running run_vo-dml_all target !" />
200 <for list="${models}" param="model">
201 <sequential>
202 <ant target="vo-dml2html" inheritall="false">
203 <property name="model" value="@{model}"/>
204 </ant>
205 </sequential>
206 </for>
207 </target>
208
209
210 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
211 <target name="run_vo-dml2rdf" depends="set-ant-contrib"
212 description="generate HTML documentation for all indicated models, requires ant-contrib">
213 <fail unless="models" message="Must define property 'models' in build.properties before running run_vo-dml_all target !" />
214 <for list="${models}" param="model">
215 <sequential>
216 <ant target="vo-dml2rdf" inheritall="false">
217 <property name="model" value="@{model}"/>
218 </ant>
219 </sequential>
220 </for>
221 </target>
222
223
224 <!-- =========================================================================================== -->
225 <!-- Targets to be run when ant.contrib,jar is not set and input parameter in build.properties MUST identify a single model -->
226 <!-- =========================================================================================== -->
227
228 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
229 <!-- Target: schematron-compile -->
230 <!-- Description: -->
231 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
232 <target name="schematron-compile">
233 <xslt2 basedir="." style="./schematron/iso_svrl_for_xslt2.xsl" in="${xsd}/vo-dml.v1.0.sch.xml" out="${xslt}/vo-dml.sch.xsl" />
234 </target>
235
236 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
237 <!-- Target: xmi2vo-dml -->
238 <!-- Description: Translate single model from XMI to vo-dml/xml -->
239 <!-- then generate vodml-ids -->
240 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
241 <target name="xmi2vo-dml" if="xmi.source">
242 <fail unless="model" message="Must define property 'model' in build.properties !" />
243 <fail unless="xmi.source.profile" message="Must define property 'xmi.source.profile' in ${model}/vo-dml.properties (the profile according to which XMI file is structured) !" />
244 <echo> Running xmi2vo-dml for ${model}/${xmi.source}</echo>
245 <xslt2 in="${model}/${xmi.source}" out="${vo-dml.dir}/__TEMP__.vo-dml.xml" style="${xslt}/xmi2vo-dml_${xmi.source.profile}.xsl"/>
246 <xslt2 in="${vo-dml.dir}/__TEMP__.vo-dml.xml" out="${vo-dml.dir}/${vo-dml.source}" style="${xslt}/generate-utypes4vo-dml.xsl"/>
247 </target>
248
249 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
250 <!-- Target: validate_vo-dml -->
251 <!-- Description: validate vo-dml file using schematron schema -->
252 <!-- TODO add validation by schema itself -->
253 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
254 <target name="validate_vo-dml" depends="schematron-compile" if="model">
255 <echo>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</echo>
256 <echo>Validating against schema, writing :</echo>
257 <echo>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</echo>
258 <echo>Validating against schematron, output written to ${vo-dml.dir}/${vo-dml.source}.svrlt:</echo>
259 <echo>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</echo>
260 <xslt2 basedir="${xslt}" style="${xslt}/vo-dml.sch.xsl" in="${vo-dml.dir}/${vo-dml.source}" out="${vo-dml.dir}/${vo-dml.source}.svrlt" />
261
262 <!-- find errors -->
263 <echo>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</echo>
264 <xslt2 basedir="."
265 style="${xslt}/inspect-validation-result.xsl"
266 in="${vo-dml.dir}/${vo-dml.source}.svrlt"
267 out="${vo-dml.dir}/validation.log">
268 <param name="outputfile" expression="${vo-dml.source}.validation-report.txt" />
269 </xslt2>
270 <echo>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</echo>
271 <record name="${vo-dml.dir}/${vo-dml.source}.validation-report.txt" action="start" append="yes"/>
272 <schemavalidate file="${vo-dml.dir}/${vo-dml.source}" failonerror="false" >
273 <schema namespace="http://www.ivoa.net/xml/VODML/v1.0" file="${xsd}/vo-dml-v1.0.xsd"/>
274 </schemavalidate>
275 <record name="${vo-dml.dir}/${vo-dml.source}.validation-report.txt" action="stop"/>
276 <delete file="${vo-dml.dir}/validation.log" />
277 </target>
278
279 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
280 <!-- Target: vo-dml2html -->
281 <!-- Description: generate HTML documentation for a single model -->
282 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
283 <target name="vo-dml2html" depends="vo-dml2gvd" if="model" >
284 <echo>run_vo-dml2html : starting generate HTML from file ${model}/${dm.filename.prefix}</echo>
285 <xslt2 in="${vo-dml.dir}/${vo-dml.source}" out="${html.dir}/${html.target}" style="${xslt}/vo-dml2html.xsl">
286 <param name="project_name" expression="${dm.filename.prefix}" />
287 <param name="graphviz_png" if="graphviz.path" expression="${graphviz.png}" />
288 <param name="graphviz_map" if="graphviz.path" expression="${graphviz.map.placeholder}" />
289 <param name="preamble" expression="${html.preamble}" />
290 </xslt2>
291 <ant target="postGenerateHTML" />
292 <echo>run_vo-dml2html : done.</echo>
293 </target>
294
295 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
296 <!-- Target: vo-dml2gvd -->
297 <!-- Description: generates Object Graphs (graphviz tool) for a single -->
298 <!-- vo-dml model, then generate model diagrams and a cmap -->
299 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
300 <target name="vo-dml2gvd" if="graphviz.path">
301 <fail unless="model" message="Must define property 'model' !" />
302 <echo>run_vo-dml2gvd : starting generate GraphViz from file ${vo-dml.dir}/${vo-dml.source}</echo>
303 <xslt2 in="${vo-dml.dir}/${vo-dml.source}" out="${html.dir}/${graphviz.gvd}" style="${xslt}/vo-dml2gvd.xsl" />
304 <exec executable="${graphviz.path}" dir="${html.dir}">
305 <arg value="-Tcmapx" />
306 <arg value="-o${graphviz.map}" />
307 <arg value="-Tpng" />
308 <arg value="-o${graphviz.png}" />
309 <arg value="${graphviz.gvd}" />
310 </exec>
311 <echo>run_vo-dml2gvd : done.</echo>
312 </target>
313
314 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
315 <!-- Target: postGenerateHTML -->
316 <!-- Description: -->
317 <!-- if a cmap file is created, insert it in the HTML file -->
318 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
319 <target name="postGenerateHTML" if="graphviz.path">
320 <loadfile property="map" srcfile="${html.dir}/${graphviz.map}" />
321 <replace file="${html.dir}/${html.target}" token="${graphviz.map.placeholder}" value="${map}" />
322 </target>
323
324
325 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
326 <target name="validate_vo-dml-instance" >
327 <echo>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</echo>
328 <echo>Validating against schema, writing :</echo>
329 <schemavalidate file="${vo-dml-instance.file}" failonerror="false" >
330 <schema namespace="http://volute.g-vo.org/dm/vo-dml-instance/v0.x" file="${xsd}/vo-dml-instance.xsd"/>
331 </schemavalidate>
332 </target>
333
334 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
335 <target name="validateVOTable" description="For testing an annotated VOTable file against the updated VOTable schema">
336 <schemavalidate file="${votable.file}" failonerror="false" >
337 <schema namespace="http://www.ivoa.net/xml/VOTable/v1.4_vodml"
338 file="${xsd}/ext/VOTable-1.4_vodml.xsd"/>
339 </schemavalidate>
340 </target>
341
342 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
343 <target name="vo-dml2rdf" if="model">
344 <echo>vo-dml2html : starting generate RDF from file ${model}/${dm.file.prefix}</echo>
345 <xslt2 in="${model}/${vo-dml.source}" out="${model}/${rdf.target}" style="${xslt}/vo-dml2rdf.xsl"/>
346 <echo>run_vo-dml2rdf : done.</echo>
347 </target>
348
349
350 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
351 <target name="run_vo-dml2pojo" description="Generate POJO java classes for all models identified in mapping.file">
352 <fail unless="mapping.file" message="Must define property 'mapping.file' in build.properties (the source VO-DML file) !" />
353 <echo>run_vo-dml2pojo : starting generate Java code for all models in mapping file ${mapping.file}</echo>
354 <xslt2 in="${mapping.file}" out="${java.gen}/run_pojo.txt" style="${xslt}/vo-dml2pojo.xsl">
355 <param name="mapping_file" expression="${mapping.file}" />
356 <param name="vo-dml_package" expression="${vodml.package}" />
357 </xslt2>
358 <ant target="format"/>
359 </target>
360
361 <!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
362 <target name="run_vo-dml2xsd" description="Generate XML schema files for all models identified in mapping.file">
363 <fail unless="mapping.file" message="Must define property 'mapping.file' in build.properties (the source VO-DML file) !" />
364 <echo>run_vo-dml2xsd : starting generate XML schema files for all models in mapping file ${mapping.file}</echo>
365 <xslt2 in="${mapping.file}" out="${xsd.gen}/run_xsd.txt" style="${xslt}/vo-dml2xsd.xsl">
366 <param name="mapping_file" expression="${mapping.file}" />
367 <param name="schemalocation_root" expression="${schemalocation_root}" />
368 </xslt2>
369 </target>
370
371
372 <!-- transformation from XSD to Java classes suited for XmlPullParser -->
373 <target name="run_vo-dml-xsd2java" description="Generate Java classes form XML schema">
374 <echo>run_xsd2java : starting generate XML schema files for all models in mapping file ${mapping.file}</echo>
375 <xslt2 in="${xsd}/vo-dml-v1.0.xsd" out="${sources}/log_xsd2pojo.txt" style="${xslt}/xsd2pojo.xsl">
376 <param name="dir" expression="org/ivoa/vodml/xml/gen" />
377 <param name="package" expression="org.ivoa.vodml.xml.gen" />
378 </xslt2>
379 </target>
380
381
382 <!-- include java realated targets for compiling generated code and generating some infrastructure classes
383 using JAXB. Latter targets require value for jaxb.dir property in build.properties -->
384 <!--
385 -->
386 &buildJava;
387
388 </project>

msdemlei@ari.uni-heidelberg.de
ViewVC Help
Powered by ViewVC 1.1.26