forked from apache/ddlutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
472 lines (432 loc) · 20.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
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project default="dist"
name="DdlUtils"
basedir=".">
<!-- Allow values set at the commandline or in the environment to override the defaults -->
<property environment="env"/>
<!-- Load the build properties -->
<property file="build.properties"/>
<!-- The classpath used for compiling and generating the documentation -->
<path id="compilation-classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
<pathelement path="${build.java.dir}"/>
<pathelement path="${build.test.dir}"/>
</path>
<target name="init"
description="Initializes the build process">
<tstamp/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.java.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="compile"
description="Compiles the code"
depends="init">
<javac srcdir="${src.java.dir}"
destdir="${build.java.dir}"
deprecation="true"
debug="true"
source="1.2"
target="1.2"
optimize="false">
<classpath refid="compilation-classpath"/>
</javac>
<copy todir="${build.java.dir}">
<fileset dir="${src.java.dir}"
excludes="**/*.java,**/*.html"/>
</copy>
</target>
<target name="jar"
description="Creates the jar"
depends="compile">
<copy todir="${build.java.dir}">
<fileset dir="${src.java.dir}"
excludes="**/*.java"/>
</copy>
<mkdir dir="${build.java.dir}/META-INF"/>
<copy todir="${build.java.dir}/META-INF"
file="${basedir}/LICENSE.txt"/>
<jar jarfile="${dist.dir}/${dist.filename.prefix}.jar"
basedir="${build.java.dir}"
excludes="**/package.html">
<manifest>
<attribute name="Built-By" value="${java.version} (${java.vendor})"/>
<attribute name="Package" value="org.apache.ddlutils"/>
<attribute name="Extension-Name" value="ddlutils"/>
<attribute name="Specification-Version" value="${dist.version}"/>
<attribute name="Specification-Vendor" value="${dist.vendor}"/>
<attribute name="Specification-Title" value="${dist.name}"/>
<attribute name="Implementation-Version" value="${dist.version}"/>
<attribute name="Implementation-Vendor" value="${dist.vendor}"/>
</manifest>
</jar>
</target>
<target name="clean"
description="Cleans up the generated directories">
<delete failonerror="false"
dir="${build.dir}"/>
<delete failonerror="false"
dir="${dist.dir}"/>
</target>
<!-- ================================================================== -->
<!-- Build the documentation -->
<!-- ================================================================== -->
<target name="doc"
description="Builds the complete documentation">
<fail message="Please set the FORREST_HOME environment variable to the 'src/core' subdirectory of your Forrest installation. If you don't have yet installed Forrest, you can get it from http://forrest.apache.org.">
<condition>
<not>
<isset property="env.FORREST_HOME"/>
</not>
</condition>
</fail>
<available classname="org.apache.xml.resolver.Resolver" property="commons.resolver.available"/>
<fail unless="commons.resolver.available" message="Please make the Apache XML Commons Resolver library available in the classpath, e.g. by copying the xml-commons-resolver jar file from the 'tools/ant/lib' subdirectory of your Forrest installation (${env.FORREST_HOME}/tools/ant/lib) into the lib subdirectory of your Ant installation (${env.ANT_HOME}/lib)."/>
<delete dir="${build.doc.dir}"
failonerror="false"/>
<mkdir dir="${build.doc.dir}"/>
<!-- Copy all forrest src stuff to a temporary directoy -->
<copy todir="${build.doc.dir}">
<fileset dir="${src.doc.dir}"/>
</copy>
<!-- Copy generated javadoc into the forrest structure in the temporary directory -->
<antcall target="javadoc"/>
<copy todir="${forrest.javadoc.destdir}">
<fileset dir="${build.javadoc.dir}"/>
</copy>
<!-- Copy generated schema doc into the forrest structure in the temporary directory -->
<antcall target="schemadoc"/>
<copy todir="${forrest.schemadoc.destdir}">
<fileset dir="${build.schemadoc.dir}"/>
</copy>
<!-- Copy generated ant doc into the forrest structure in the temporary directory -->
<antcall target="antdoc"/>
<copy todir="${forrest.antdoc.destdir}">
<fileset dir="${build.antdoc.dir}"/>
</copy>
<ant antfile="${env.FORREST_HOME}/main/forrest.build.xml"
dir="${build.doc.dir}"
inheritall="false"
target="site">
<property name="forrest.home" value="${env.FORREST_HOME}"/>
</ant>
<!-- Finally we can copy the generated documentation to its designated place -->
<mkdir dir="${doc.dir}"/>
<copy todir="${doc.dir}">
<fileset dir="${forrest.output.dir}"/>
</copy>
</target>
<target name="-docbook">
<mkdir dir="${build.doc.dir}"/>
<copy todir="${build.doc.dir}">
<fileset dir="../velocity-docbook/"/>
</copy>
<mkdir dir="${build.doc.dir}/src/docbook/ddlutils"/>
<copy file="${src.doc.dir}/manual.xml" todir="${build.doc.dir}/src/docbook/ddlutils"/>
<ant antfile="build-docbook.xml" target="all" inheritall="false" dir="${build.doc.dir}">
<property name="docbook.dir" value="ddlutils"/>
<property name="docbook.file" value="manual"/>
</ant>
</target>
<!-- ================================================================== -->
<!-- Build the API JavaDocs -->
<!-- ================================================================== -->
<target name="javadoc"
depends="init"
description="Builds the API javadocs.">
<mkdir dir="${build.javadoc.dir}"/>
<javadoc sourcepath="${src.java.dir}"
classpathref="compilation-classpath"
destdir="${build.javadoc.dir}"
doctitle="${javadoc.title}"
windowtitle="${javadoc.title}"
bottom="${javadoc.footer}"
protected="true"
author="false"
version="true"
packagenames="org.*">
<tag name="ant.type" scope="types" description="Marks an ant type"/>
<tag name="ant.task" scope="types" description="Marks an ant task"/>
<tag name="ant.required" scope="methods" description="Marks a required task property"/>
<tag name="ant.not-required" scope="methods" description="Marks an optional task property"/>
<link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
<link href="http://jakarta.apache.org/commons/lang/apidocs/"/>
<link href="http://jakarta.apache.org/commons/beanutils/apidocs/"/>
<link href="http://jakarta.apache.org/commons/digester/apidocs/"/>
<link href="http://jakarta.apache.org/commons/betwixt/apidocs/"/>
</javadoc>
</target>
<!-- ================================================================== -->
<!-- Builds the documentation for the database XML schema format -->
<!-- ================================================================== -->
<target name="schemadoc"
description="Builds the documentation for the database XML schema format">
<available classname="DTDDoc.DTDDocTask"
classpathref="compilation-classpath"
property="dtddoc.available"/>
<fail unless="dtddoc.available" message="For building the XML Schema documentaion, you'll need DTDDoc which can be downloaded from http://sourceforge.net/projects/dtddoc. Please make the DTDDoc and dtdparser jars available in the classpath."/>
<taskdef name="dtddoc"
classname="DTDDoc.DTDDocTask"
classpathref="compilation-classpath"/>
<mkdir dir="${build.schemadoc.dir}"/>
<dtddoc destdir="${build.schemadoc.dir}" sourcedir="${src.java.dir}" includes="*.dtd"/>
</target>
<!-- ================================================================== -->
<!-- Builds the documentation for the Ant tasks -->
<!-- ================================================================== -->
<target name="antdoc"
description="Builds the documentation for the Ant tasks">
<available classname="com.neuroning.antdoclet.AntDoclet"
classpathref="compilation-classpath"
property="antdoc.available"/>
<fail unless="antdoc.available" message="For building the Ant task documentaion, you'll need AntDoc which can be downloaded from http://antdoclet.neuroning.com/. Please make the AntDoc libraries available in the classpath."/>
<mkdir dir="${build.antdoc.dir}"/>
<javadoc sourcepath="${src.java.dir}"
classpathref="compilation-classpath"
destdir="${build.antdoc.dir}"
doctitle="${antdoc.title}"
protected="true"
author="false"
version="true"
packagenames="org.apache.ddlutils.task">
<doclet name="com.neuroning.antdoclet.AntDoclet"
pathref="compilation-classpath">
<param name="-templatesdir" value="${antdoc.templates.dir}"/>
<param name="-templates" value="html/main.vm" />
</doclet>
</javadoc>
<copy todir="${build.antdoc.dir}">
<fileset dir="${src.antdoc.dir}" includes="*.css,*.js"/>
<fileset dir="${antdoc.templates.dir}/html" includes="*.htm*"/>
</copy>
</target>
<!-- ================================================================== -->
<!-- Checks the docs for broken links -->
<!-- ================================================================== -->
<target name="check-doc"
description="Checks the doc for broken links using linklint">
<echo>Running linklint on ${build.doc.dir}. The output can be found in linklint.log.</echo>
<exec executable="linklint">
<arg line="-quiet"/>
<arg line="-net"/>
<arg line="-error"/>
<arg line="-warn"/>
<arg line="-out"/>
<arg line="linklint.log"/>
<arg line="-root"/>
<arg line="${forrest.output.dir}"/>
<arg line="/@"/>
</exec>
</target>
<!-- ================================================================== -->
<!-- Build the doc archive -->
<!-- ================================================================== -->
<target name="doc-archive" depends="doc"
description="Builds the complete documentation archive.">
<zip zipfile="${dist.dir}/${dist.doc.filename.prefix}.zip"
basedir="."
includes="${dist.doc.includes}"/>
</target>
<!-- ================================================================== -->
<!-- Build the src archive -->
<!-- ================================================================== -->
<target name="src-archive" depends="doc"
description="Builds the source distribution archive.">
<zip zipfile="${dist.dir}/${dist.src.filename.prefix}.zip"
basedir="."
includes="${dist.src.includes}"
excludes="${dist.src.excludes}"/>
</target>
<!-- ================================================================== -->
<!-- Build the bin archive -->
<!-- ================================================================== -->
<target name="bin-archive" depends="jar,doc"
description="Builds the binary distribution archive.">
<zip zipfile="${dist.dir}/${dist.bin.filename.prefix}.zip"
basedir="."
includes="${dist.bin.includes}"
excludes="${dist.bin.excludes}"/>
</target>
<!-- ================================================================== -->
<!-- Creates the DdlUtils distribution -->
<!-- ================================================================== -->
<target name="dist"
description="Creates the distribution"
depends="jar, doc-archive, src-archive, bin-archive"/>
<target name="compile-tests"
description="Compiles the unit tests"
depends="compile">
<mkdir dir="${build.test.dir}"/>
<javac srcdir="${src.test.dir}"
destdir="${build.test.dir}"
deprecation="true"
debug="true"
source="1.2"
target="1.2"
optimize="false">
<classpath refid="compilation-classpath"/>
</javac>
</target>
<!-- ================================================================== -->
<!-- Can be used to create the testdatabase if the platform supports it -->
<!-- ================================================================== -->
<target name="create-test-database"
description="Can be used to create the testdatabase if the platform supports it">
<property file="${jdbc.properties.file}"/>
<taskdef name="ddl2Database"
classname="org.apache.ddlutils.task.DdlToDatabaseTask"
classpathref="compilation-classpath"/>
<ddl2Database>
<database driverclassname="${datasource.driverClassName}"
url="${datasource.url}"
username="${datasource.username}"
password="${datasource.password}"/>
<createdatabase failonerror="true"/>
</ddl2Database>
</target>
<!-- ================================================================== -->
<!-- Runs the test cases -->
<!-- ================================================================== -->
<target name="junit"
description="Runs the test cases against no database or the one specified via -Djdbc.properties.file">
<antcall target="-junit-internal"/>
</target>
<!-- ================================================================== -->
<!-- Runs the test cases against AxionDB -->
<!-- ================================================================== -->
<target name="junit-axion"
description="Runs the test cases against Axion">
<property name="jdbc.properties.file" value="/jdbc.properties.axion"/>
<antcall target="-junit-internal"/>
</target>
<!-- ================================================================== -->
<!-- Runs the test cases against Derby -->
<!-- ================================================================== -->
<target name="junit-derby"
description="Runs the test cases against Derby">
<property name="jdbc.properties.file" value="/jdbc.properties.derby"/>
<antcall target="-junit-internal"/>
</target>
<!-- ================================================================== -->
<!-- Runs the test cases against HsqlDb -->
<!-- ================================================================== -->
<target name="junit-hsqldb"
description="Runs the test cases against Hsqldb">
<property name="jdbc.properties.file" value="/jdbc.properties.hsqldb"/>
<antcall target="-junit-internal"/>
</target>
<!-- ================================================================== -->
<!-- Runs the test cases against MySQL -->
<!-- ================================================================== -->
<target name="junit-mysql"
description="Runs the test cases against MySql">
<property name="jdbc.properties.file" value="/jdbc.properties.mysql"/>
<antcall target="-junit-internal"/>
</target>
<!-- ================================================================== -->
<!-- Runs the test cases against PostgreSQL -->
<!-- ================================================================== -->
<target name="junit-postgresql"
description="Runs the test cases against PostgreSQL">
<property name="jdbc.properties.file" value="/jdbc.properties.postgresql"/>
<antcall target="-junit-internal"/>
</target>
<target name="-junit-internal"
depends="compile-tests">
<junit dir="."
printSummary="yes"
fork="true"
haltonerror="false">
<sysproperty key="jdbc.properties.file" value="${jdbc.properties.file}"/>
<formatter type="xml"/>
<formatter type="plain"/>
<classpath refid="compilation-classpath"/>
<batchtest todir="${build.test.dir}">
<fileset dir="${src.test.dir}" includes="**/Test*.java">
<exclude name="**/Test*Base.java"/>
<exclude name="**/TestPlatform.java"/>
<exclude name="**/TestSummaryCreatorTask.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- ================================================================== -->
<!-- Creates the test report -->
<!-- ================================================================== -->
<target name="junit-report"
description="Creates a test report in html form">
<junitreport todir="${build.test.dir}">
<fileset dir="${build.test.dir}" casesensitive="false">
<include name="test*.xml"/>
</fileset>
<report format="frames"
todir="${build.test.dir}"/>
</junitreport>
</target>
<!-- ================================================================== -->
<!-- Creates the test summary -->
<!-- ================================================================== -->
<target name="junit-summary"
depends="compile-tests"
description="Creates a test summary">
<taskdef name="testSummary"
classname="org.apache.ddlutils.TestSummaryCreatorTask"
classpathref="compilation-classpath"/>
<testSummary version="${dist.version}"
outputfile="${build.test.dir}/summary.xml">
<fileset dir="${build.test.dir}"
casesensitive="false">
<include name="test*.xml"/>
</fileset>
</testSummary>
<property name="test.summary.stylesheet" value="${test.summary.dir}/moinmoin.xsl"/>
<style in="${build.test.dir}/summary.xml"
style="${test.summary.stylesheet}"
out="${build.test.dir}/summary.txt"/>
</target>
<!-- ================================================================== -->
<!-- Runs Checkstyle over DdlUtils -->
<!-- ================================================================== -->
<target name="checkstyle"
description="Checks the sourcecode via Checkstyle">
<fail message="Due to licensing issues, DdlUtils is not distributed with Checkstyle. If you want to use this task, then please put the checkstyle jar into the lib subdirectory.">
<condition>
<not>
<available classpathref="compilation-classpath"
resource="checkstyletask.properties"/>
</not>
</condition>
</fail>
<taskdef resource="checkstyletask.properties"
classpathref="compilation-classpath"/>
<checkstyle config="${src.check.dir}/ddlutils-checks.xml"
failOnViolation="false">
<fileset dir="${src.java.dir}"
includes="**/*.java"/>
<fileset dir="${src.test.dir}"
includes="**/*.java"/>
<formatter type="plain" usefile="false"/>
<!-- Location of cache-file (project specific) -->
<property key="checkstyle.cache.file" file="${build.check.dir}/checkstyle/cachefile"/>
</checkstyle>
</target>
</project>