forked from FasterXML/aalto-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
384 lines (346 loc) · 16.2 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
<?xml version="1.0" standalone='yes'?>
<project name="Aalto XML processor" basedir="." default="readme">
<!-- Source directories -->
<property name="dir.src" location="${basedir}/src" />
<property name="dir.src.java" location="${dir.src}/main/java" />
<property name="dir.src.test" location="${dir.src}/test/java" />
<property name="dir.resources" location="${dir.src}/main/resources" />
<property name="dir.releasenotes" location="${basedir}/release-notes" />
<!-- Libs -->
<property name="dir.lib" location="${basedir}/lib" />
<!-- Build-related -->
<property name="dir.build" location="${basedir}/build" />
<property name="dir.build.classes" location="${dir.build}/classes" />
<!-- Documentation -->
<property name="dir.doc" location="${basedir}/doc" />
<property name="dir.javadoc" location="${dir.build}/javadoc" />
<!-- Test suite -->
<property name="dir.test" location="${basedir}/test" />
<property name="dir.classes.test" location="${dir.test}/classes" />
<property name="TestResultsDir" location="${dir.test}/results" />
<property name="TestXmlResultsDir" location="${TestResultsDir}/xml" />
<property name="StaxTestClassesDir" location="${dir.test}/staxtest-classes" />
<!-- Distribution -->
<property name="dir.dist" location="${basedir}/dist" />
<!-- Version information -->
<property name="STAX_TITLE" value="StAX 1.0 API" />
<property name="STAX_VERSION" value="1.0" />
<property name="STAX_VENDOR" value="http://jcp.org/en/jsr/detail?id=173" />
<property name="IMPL_TITLE" value="Aalto XML-processor" />
<property name="IMPL_VERSION" value="0.9.5" />
<property name="IMPL_VENDOR" value="fasterxml.com" />
<!-- jars needed for compilation -->
<path id="classpath.compile">
<fileset dir="${dir.lib}" includes="stax-api*.jar" />
<fileset dir="${dir.lib}" includes="stax2*.jar" />
</path>
<path id="libs.junit">
<fileset dir="${dir.lib}">
<include name="test/junit*.jar" />
</fileset>
</path>
<!-- Source files to include in source packages (tar, zip) -->
<patternset id="dist-all-src-files">
<include name="src/**/*.java" />
<include name="src/test/**/*.xml" />
<include name="src/test/**/*.dtd" />
<include name="src/java/**/*.html" />
<include name="src/resources/*" />
<include name="release-notes/*" />
<include name="release-notes/gpl/*" />
<include name="build.xml" />
<include name="project.xml" />
<!-- need jars too; at least the api jar, but let's copy
all for now... it's nice to have the unit tests in there
too. This way src packages are proper subsets of binary ones
-->
<include name="lib/*.jar" />
<include name="lib/test/*.jar" />
</patternset>
<!--*********************************************************************-->
<!-- The readme target shows a brief description of all targets -->
<!-- supported by this ant build file -->
<!--*********************************************************************-->
<target name="readme">
<echo message="${ant.project.name}'s Available Targets" />
<echo message="---------------------------------------------------" />
<echo message="1) readme - Displays this information (default target)." />
<echo message="2) clean - Remove any generated files/directories." />
<echo message="3) compile - Compile all non-test ${ProjectName} code." />
<echo message="4) jars - Compile and create all jars for non-test ${ProjectName} code (see below for specific ones)." />
<echo message="4a) jar.aalto.gpl - Compile and create jar for non-test ${ProjectName} cod, under GPL 3.0 license." />
<echo message="4b) jar.j2me - Compile and create minimal non-test jar of ${ProjectName}, that implements J2ME subset of StAX." />
<echo message="5) javadoc - Generate ${ProjectName} code documentation." />
<echo message="6) test.compile - Compile ${ProjectName} code and test code" />
<echo message=" for JUnit tests." />
<echo message="7a) test - Run impl-specific JUnit tests." />
<echo message="7b) staxtest - Run generic StAX JUnit tests." />
<echo message="8) dist - Create distribution directory and copy necessary files there" />
<echo message="9) all - Run the clean, compile, javadoc," />
<echo message=" test and dist targets." />
</target>
<target name="prepare">
<!-- make build directories -->
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.build.classes}" />
<!-- make docs directories -->
<mkdir dir="${dir.doc}" />
<mkdir dir="${dir.javadoc}" />
<!-- make test output directories -->
<mkdir dir="${dir.test}" />
<mkdir dir="${dir.classes.test}" />
<mkdir dir="${TestResultsDir}" />
<mkdir dir="${TestXmlResultsDir}" />
<!-- and finally distribution dir -->
<mkdir dir="${dir.dist}" />
</target>
<!-- ***********************************************
- clean - Removes all generated files/directories
- ***********************************************-->
<target name="clean">
<delete dir="${dir.build}"/>
<delete dir="${dir.doc}"/>
<delete dir="${dir.test}"/>
<delete dir="${dir.dist}"/>
<delete file="coverage.ec" />
</target>
<!-- 18-Dec-2008, tatu: Let's upgrade JDK baseline req
to 1.6; we can then use Arrays.copyOf, and other
minor (but useful) additions 1.6 has over 1.5
-->
<target name="compile" depends="prepare,copy-resources">
<javac srcdir="${dir.src.java}" destdir="${dir.build.classes}"
source="1.6" target="1.6"
debug="true" includeantruntime="false"
>
<include name="com/fasterxml/**/*.java" />
<include name="test/**/*.java" />
<classpath refid="classpath.compile" />
</javac>
</target>
<target name="copy-resources" depends="prepare">
<mkdir dir="${dir.build.classes}/META-INF/services" />
<copy toDir="${dir.build.classes}/META-INF/services"> <fileset dir="${dir.resources}">
<include name="javax.xml.stream.*" />
</fileset>
</copy>
</target>
<!-- Dummy target that just includes all individual jars... -->
<target name="jars"
depends="jar.aalto.gpl, jar.resources"
/>
<target name="jar.aalto.gpl" depends="compile,copy-resources">
<jar jarfile="${dir.build}/aalto-gpl-${IMPL_VERSION}.jar" filesonly="true" >
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Specification-Title" value="${STAX_TITLE}"/>
<attribute name="Specification-Version" value="${STAX_VERSION}"/>
<attribute name="Specification-Vendor" value="${STAX_VENDOR}"/>
<attribute name="Implementation-Title" value="${IMPL_TITLE}"/>
<attribute name="Implementation-Version" value="${IMPL_VERSION}"/>
<attribute name="Implementation-Vendor" value="${IMPL_VENDOR}"/>
</manifest>
<fileset dir="${dir.build.classes}">
<include name="com/fasterxml/**/*.class" />
<include name="META-INF/services/javax.xml.stream.*" />
</fileset>
<!-- Looks like Maven expects to find license under
META-INF. Fine.
-->
<metainf dir="${dir.releasenotes}/gpl" includes="*" />
</jar>
</target>
<!-- This jar is only needed for testing purposes, to specify
- which StAX implementation to use
-->
<target name="jar.resources" depends="compile,copy-resources">
<jar jarfile="${dir.build}/service-def-${IMPL_VERSION}.jar">
<fileset dir="${dir.build.classes}">
<include name="META-INF/services/javax.xml.stream.*" />
</fileset>
</jar>
</target>
<target name="javadoc" depends="prepare">
<!-- Build a dirpath that contains just the "source" tree -->
<javadoc windowtitle="${ProjectName}"
destdir="${dir.javadoc}"
author="true"
version="true">
<packageset dir="${dir.src.java}" defaultexcludes="yes">
<include name="com/fasterxml/**" />
</packageset>
<classpath refid="classpath.compile" />
</javadoc>
</target>
<target name="dist" depends="compile,jars,javadoc"
>
<!-- First, let's copy the binary jars to dist -->
<copy todir="${dir.dist}">
<fileset dir="${dir.build}" includes="aalto*.jar" />
<!-- And also stax2-api jar we need: -->
<fileset dir="${dir.lib}" includes="stax2-api*.jar" />
</copy>
<!-- Then let's create the source distribution tar packages
-->
<!-- Need to first copy to a tmp dir, to get the additional
directory (so tar/zip contents won't explode directly
in current dir)
-->
<property name="DIST_FILENAME" value="aalto-src-${IMPL_VERSION}" />
<property name="DIST_DIR" value="${DIST_FILENAME}" />
<!-- better always clean it up, if it exists... -->
<delete dir="${dir.build}/${DIST_DIR}" />
<mkdir dir="${dir.build}/${DIST_DIR}" />
<copy todir="${dir.build}/${DIST_DIR}">
<fileset dir="${basedir}">
<patternset refid="dist-all-src-files" />
</fileset>
</copy>
<!-- then create tarball, zip -->
<tar basedir="${dir.build}"
includes="${DIST_DIR}/**"
destfile="${dir.dist}/${DIST_FILENAME}.tar.gz"
compression="gzip"
/>
<zip basedir="${dir.build}"
includes="${DIST_DIR}/**"
destfile="${dir.dist}/${DIST_FILENAME}.zip"
/>
<!-- Then copy javadocs -->
<copy todir="${dir.dist}">
<fileset dir="${dir.javadoc}/.." includes="javadoc/**/*" />
</copy>
<!-- Plus, let's also just copy README and compatibility files, in
addition to being included in source package
-->
<copy todir="${dir.dist}" >
<fileset dir="." includes="release-notes/*" />
<fileset dir="." includes="release-notes/gpl/*" />
</copy>
</target>
<target name="all" depends="clean,javadoc,test,dist">
<!-- This target simply depends on others to do its job -->
</target>
<!--*********************************************************************-->
<!-- Tasks from here down are in support of junit tests. -->
<!--*********************************************************************-->
<target name="all-tests" depends="test,staxtest" />
<!-- Running generic StAX tests -->
<target name="staxtest" depends="prepare-staxtest">
<!-- showoutput 'yes' to allow outputting debug msgs... -->
<junit fork="no" printsummary="yes" haltonfailure="no"
showoutput="yes">
<sysproperty key="javax.xml.stream.XMLInputFactory" value="com.fasterxml.aalto.stax.InputFactoryImpl"/>
<sysproperty key="javax.xml.stream.XMLOutputFactory" value="com.fasterxml.aalto.stax.OutputFactoryImpl"/>
<sysproperty key="javax.xml.stream.XMLEventFactory" value="com.fasterxml.aalto.stax.EventFactoryImpl" />
<sysproperty key="" value=""/>
<batchtest fork="no" todir="${TestXmlResultsDir}">
<fileset dir="${StaxTestClassesDir}">
<!-- Need to exclude inner classes... -->
<exclude name="**/*$*.class"/>
<!-- As well as (for now) validating-writer tests and DTD handling -->
<exclude name="org/codehaus/stax/test/dtd/*.class"/>
<exclude name="org/codehaus/stax/test/vstream/*.class"/>
<exclude name="stax2/dtd/**/*.class"/>
<exclude name="stax2/vwstream/**/*.class"/>
<include name="org/codehaus/stax/test/**/Test*.class"/>
<include name="stax2/**/Test*.class"/>
</fileset>
</batchtest>
<formatter type="xml" />
<classpath refid="classpath.compile" />
<classpath path="${StaxTestClassesDir}" />
<classpath>
<pathelement path="${dir.build.classes}" />
<!-- Note: need to add the dummy aalto.jar, since it has properties
- to point StAX to use correct implementation classes!
-->
<fileset dir="${dir.build}">
<include name="service-def-*.jar" />
</fileset>
<path refid="libs.junit"/>
</classpath>
</junit>
<junitreport todir="${TestResultsDir}">
<fileset dir="${TestXmlResultsDir}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${TestResultsDir}" />
</junitreport>
</target>
<target name="prepare-staxtest" depends="jar.resources">
<mkdir dir="${StaxTestClassesDir}" />
<!-- and unpack test classes... unfortunately needed so JUnit
can find classes (maybe there's a way to refer to a jar too,
have not found one so far)
-->
<unzip dest="${StaxTestClassesDir}" overwrite="false">
<fileset dir="${dir.lib}/test">
<include name="stax2test-*.jar" />
</fileset>
</unzip>
</target>
<!-- Compiling and running Impl-specific tests
-->
<target name="test.compile" depends="compile">
<javac srcdir="${dir.src.test}" destdir="${dir.classes.test}"
debug="true" includeantruntime="false"
>
<include name="**/*.java" />
<classpath refid="classpath.compile" />
<classpath>
<pathelement path="${dir.build.classes}"/>
<path refid="libs.junit"/>
</classpath>
</javac>
</target>
<target name="test" depends="test.compile">
<!-- showoutput 'yes' to allow outputting debug msgs... -->
<junit fork="no" printsummary="yes" haltonfailure="no"
showoutput="yes">
<batchtest fork="no" todir="${TestXmlResultsDir}">
<fileset dir="${dir.classes.test}">
<!-- Need to exclude inner classes... -->
<exclude name="**/*$*.class"/>
<include name="**/Test*.class"/>
</fileset>
</batchtest>
<formatter type="xml" />
<classpath refid="classpath.compile" />
<classpath>
<pathelement path="${dir.build.classes}" />
<pathelement location="${dir.classes.test}" />
<path refid="libs.junit"/>
</classpath>
</junit>
<junitreport todir="${TestResultsDir}">
<fileset dir="${TestXmlResultsDir}">
<include name="TEST-*.xml" />
</fileset>
<report todir="${TestResultsDir}" />
</junitreport>
</target>
<!-- Template for running individual test cases
-->
<target name="test.single" depends="test.compile">
<fail unless="test" message="Must define -Dtest" />
<junit fork="no" maxmemory="128M" showoutput="yes" printsummary="yes">
<formatter type="plain" usefile="no" />
<test name="${test}" />
<classpath refid="classpath.compile" />
<classpath>
<pathelement path="${dir.build.classes}" />
<pathelement location="${dir.classes.test}" />
<pathelement location="${Stax2TestClassesDir}" />
<path refid="libs.junit"/>
<!-- Note: need to add the dummy aalto.jar, since it has properties
- to point StAX to use correct implementation classes!
-->
<fileset dir="${dir.build}">
<include name="service-def-*.jar" />
</fileset>
<path refid="libs.junit"/>
</classpath>
</junit>
</target>
</project>