4 <!-- Default entry point for the build -->
5 <target name="all" depends="clean, init, compile, jar" />
7 <target name="startup" depends="init_directory_properties">
8 <property name="module.classpath_id" value="module.build.path" />
9 <property name="module.classpath" refid="${module.classpath_id}" />
11 <path id="module.build.path">
12 <fileset dir="${external.lib.dir}">
13 <include name="**/*.jar"/>
17 <path id="module.testbuild.path">
18 <fileset dir="${test.lib.dir}">
19 <include name="**/*.jar"/>
25 <target name="init" depends="import_header,startup">
29 <!-- ============================================================================
31 ============================================================================ -->
33 <target name="ant.deps">
36 <target name="deps" depends="import_header">
37 <antcall target="module.build.deps">
38 <param name="download.dir" value="${external.lib.dir}"/>
40 <antcall target="test.d">
41 <param name="download.dir" value="${test.lib.dir}"/>
43 <antcall target="ant.d">
44 <param name="download.dir" value="${ant.downloaded.lib.dir}"/>
46 <antcall target="module.test.deps">
47 <param name="download.dir" value="${test.lib.dir}"/>
51 <target name="clean" depends="init_directory_properties,base-test-clean">
52 <delete dir="${module.classes.dir}" />
53 <delete dir="${module.testclasses.dir}" />
54 <delete dir="${module.testoutput.dir}" />
55 <delete dir="${module.jars.dir}" />
56 <delete dir="${module.docbase.dir}" />
57 <delete dir="${module.report.dir}" />
58 <delete dir="${module.sql.dir}" />
61 <target name="clean-deps" depends="init_directory_properties">
63 <fileset dir="${external.lib.dir}" includes="*"/>
66 <fileset dir="${test.lib.dir}" includes="*"/>
69 <fileset dir="${ant.downloaded.lib.dir}" includes="*"/>
73 <!-- ============================================================================
74 Compilation of java code.
75 ============================================================================ -->
77 <!-- Compilation of java code, requires a srcdirs variable to be
78 set to a path of one of more directories separated by : or ;
80 <target name="compile-impl" depends="init">
81 <mkdir dir="${module.classes.dir}" />
82 <echo level="info" message="compile ${module.name}, source dirs ${srcdirs}" />
83 <javac srcdir="${srcdirs}" source="${javac.source}"
84 destdir="${module.classes.dir}" classpath="${module.classpath}"
85 debug="${javac.debug}" debuglevel="${javac.debug.level}" />
86 <copy todir="${module.classes.dir}">
87 <fileset dir="${module.source.dir}" excludes="**/*.java" />
91 <!-- Compilation of regular source code -->
92 <target name="compile-src" unless="ejbsource.available" depends="init">
93 <antcall target="compile-impl">
94 <param name="srcdirs" value="${module.source.dir}"/>
98 <!-- Compilation of regular source code and generated source code
100 <target name="compile-src-ejb" if="ejbsource.available" depends="init">
101 <antcall target="compile-impl">
102 <param name="srcdirs" value="${module.source.dir}:${module.ejbsource.dir}"/>
106 <target name="compile" depends="init">
107 <available file="${module.ejbsource.dir}" type="dir" property="ejbsource.available"/>
108 <antcall target="compile-src"/>
109 <antcall target="compile-src-ejb"/>
112 <!-- ============================================================================
113 Generating a jar file.
114 ============================================================================ -->
116 <target name="jar" depends="compile">
117 <mkdir dir="${module.jars.dir}" />
118 <echo level="info" message="jar cdmvbase ${module.name}" />
119 <!-- Hack: how to remove the schemas directory from the jar when it does not exist -->
120 <mkdir dir="${xmlschemas.dir}" />
121 <jar jarfile="${module.jars.dir}/${module.jar.name}"
122 compress="${jarcompress}">
123 <fileset dir="${module.classes.dir}" />
124 <fileset dir="${xmlschemas.dir}" />
129 <!-- ============================================================================
131 ============================================================================ -->
133 <target name="javadoc" depends="init">
134 <!-- create javadocs -->
135 <javadoc packagenames="*" destdir="${module.javadoc.dir}"
136 author="true" version="true" use="true" private="yes"
137 windowtitle="Dragon documentation" source="${javac.source}"
138 sourcepath="${module.source.dir}"
139 classpath="${module.classpath}">
140 <arg value="-docfilessubdirs"/>
141 <arg value="-overview"/>
142 <arg value="${module.source.dir}/overview.html"/>
146 <target name="testjavadoc" depends="testclasses">
147 <!-- create javadocs -->
148 <javadoc packagenames="*" destdir="${module.testjavadoc.dir}"
149 author="true" version="true" use="true" private="yes"
150 windowtitle="Dragon test documentation" source="${javac.source}"
151 sourcepath="${module.test.dir}"
152 classpathref="test.classpath">
156 <!-- ============================================================================
157 Generate javadoc in pdf format
158 ============================================================================ -->
160 <target name="pdfdoc" depends="init">
161 <!-- create javadocs -->
162 <mkdir dir="${module.pdfdoc.dir}" />
163 <javadoc packagenames="*" author="true" version="true" private="yes"
164 source="${javac.source}" doclet="com.tarsec.javadoc.pdfdoclet.PDFDoclet"
165 docletpathref="pdfdoclet.path"
166 classpath="${module.classpath}"
167 sourcepath="${module.source.dir}"
168 additionalparam="-pdf ${module.pdfdoc.dir}/${module.name}.pdf">
169 <!-- fileset dir="${module.source.dir}">
170 <include name="**/*.java" />
174 message="Unfortuantely, this target will have generated some errors but the pdf will still look fine" />
177 <!-- ============================================================================
179 ============================================================================ -->
181 <target name="doccheck" depends="init">
182 <mkdir dir="${module.doccheck.dir}" />
183 <javadoc packagenames="*" destdir="${module.doccheck.dir}"
184 author="true" version="true"
185 doclet="com.sun.tools.doclets.doccheck.DocCheck"
186 docletpathref="doccheck.path"
187 classpath="${module.classpath}"
188 sourcepath="${module.source.dir}">
192 <!-- ============================================================================
193 Copy build results to a standard location.
194 ============================================================================ -->
196 <target name="clean-dist" depends="clean">
198 <fileset dir="${module.dist.dir}" includes="**"/>
202 <target name="dist-lite-product" depends="jar">
203 <mkdir dir="${module.dist.dir}"/>
205 <fileset dir="${module.dist.dir}" excludes="**/CVS" />
207 <copy todir="${module.dist.dir}" flatten="yes">
208 <fileset dir="${module.build.dir}">
209 <include name="**/*.jar" />
211 <fileset dir="${module.build.dir}">
212 <include name="**/*.pdf" />
217 <target name="dist-lite-test" depends="testclasses">
218 <jar destfile="${module.dist.dir}/${module.testjar.name}"
219 basedir="${module.testclasses.dir}"
220 includes="**/*.class"/>
221 <jar destfile="${module.dist.dir}/${module.testresourcesjar.name}"
222 basedir="${module.testresource.dir}" />
225 <target name="dist-lite" depends="clean,dist-lite-product,dist-lite-test">
228 <target name="dist-javadoc" depends="javadoc,pdfdoc,testjavadoc">
229 <jar destfile="${module.dist.dir}/${module.javadocjar.name}"
230 basedir="${module.javadoc.dir}" />
231 <jar destfile="${module.dist.dir}/${module.testjavadocjar.name}"
232 basedir="${module.testjavadoc.dir}" />
233 <copy todir="${module.api.forrest.dir}">
234 <fileset dir="${module.javadoc.dir}" />
239 depends="dist-lite,dist-javadoc"
240 description="copying compiled sources to dist location and copy documentation to forrest site">
242 message="Copying build results for ${module.name} to a location where other modules can find it." />
245 <!-- ============================================================================
247 ============================================================================ -->
249 <target name="checkstyle" depends="testclasses">
250 <checkstyle config="${build.dir}/${checkstyle.rules}"
251 failOnViolation="false">
253 <path refid="module.build.path"/>
255 <fileset dir="${module.source.dir}" includes="**/*.java" />
256 <formatter type="plain" />
259 <checkstyle config="${build.dir}/${checkstyle.test.rules}"
260 failOnViolation="false">
262 <pathelement path="${module.testbuild.path}"/>
264 <fileset dir="${module.test.dir}" includes="**/*.java" />
265 <formatter type="plain" />
270 <!-- ============================================================================
271 Formatting source code.
272 ============================================================================ -->
273 <target name="format" depends="init">
274 <jalopy loglevel="INFO" classpathref="module.testbuild.path"
275 convention="${jalopy.rules}">
276 <fileset dir="${module.source.dir}">
277 <include name="**/*.java" />
279 <fileset dir="${module.test.dir}">
280 <include name="**/*.java" />
285 <!-- =========================================================================
286 Check redundancy in the code
287 ========================================================================= -->
288 <target name="simian" depends="init">
289 <simian threshold="7">
290 <fileset dir="${module.source.dir}" includes="**/*.java" />
295 <!-- =========================================================================
296 Check dependencies using macker.
297 ========================================================================= -->
298 <property name="macker.file" value="macker.xml" />
299 <target name="macker" depends="compile">
300 <available file="${macker.file}" property="macker.file.found" />
301 <fail message="Macker source file ${macker.file} was not found."
302 unless="macker.file.found" />
304 <rules dir="." includes="macker.xml" />
305 <classes dir="${module.classes.dir}">
306 <include name="**/*.class" />
309 <pathelement path="${module.classes.dir}" />
310 <path refid="module.build.path" />
316 <!-- ===========================================================================
318 =========================================================================== -->
320 <target name="testclasses" depends="compile">
321 <mkdir dir="${module.test.dir}" />
322 <mkdir dir="${module.testresource.dir}" />
323 <mkdir dir="${module.testclasses.dir}" />
324 <path id="test.classpath">
325 <pathelement path="${module.classes.dir}" />
326 <pathelement path="${module.test.dir}" />
327 <path refid="module.testbuild.path" />
328 <path refid="module.build.path" />
330 <javac srcdir="${module.test.dir}"
331 destdir="${module.testclasses.dir}"
332 debug="${javac.debug}" debuglevel="${javac.debug.level}" compiler="modern"
333 source="${javac.source}" failonerror="yes">
335 <path refid="test.classpath"/>
338 <copy todir="${module.testclasses.dir}">
339 <fileset dir="${module.test.dir}" excludes="**/*.java" />
340 <fileset dir="${module.testresource.dir}" />
344 <!-- test-base is a target mean to be used by other targets.
345 It expects one parameter names 'testedclasses' to indicate the directory
346 where the compiled test classes reside.
349 <target name="base-test-clean">
350 <delete file="coverage.ec"/>
351 <delete file="coverage.em"/>
355 <target name="base-test-impl" depends="testclasses">
356 <mkdir dir="${module.report.dir}" />
357 <antcall target="emma"/>
358 <junit haltonfailure="${junit.halt.on.failure}" printsummary="on" dir="." fork="yes" showoutput="yes">
359 <batchtest todir="${module.report.dir}">
360 <fileset dir="${module.testclasses.dir}">
361 <include name="${testclassnames}" />
362 <!-- exclude inner classes -->
363 <exclude name="**/*$$*.class"/>
366 <formatter type="xml" />
368 <path refid="xmlschemas.path" />
369 <pathelement path="${module.testclasses.dir}" />
370 <pathelement path="${testedclasses}" />
371 <pathelement path="${testlibrary}" />
372 <pathelement path="${module.classes.dir}" />
373 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
374 <!-- the test resource directory is added to the path as well to make it
375 easy to access resources from tests -->
376 <pathelement path="${module.testresource.dir}" />
377 <path refid="module.testbuild.path" />
378 <path refid="module.build.path" />
383 <target name="base-test-allclasses" unless="test">
384 <echo>Testing all classes</echo>
385 <antcall target="base-test-impl">
386 <param name="testclassnames" value="**/*Test.class" />
390 <target name="base-test-singleclass" if="test">
391 <echo>Testing testcases that conform to the pattern *${test}*</echo>
392 <antcall target="base-test-impl">
393 <param name="testclassnames" value="**/*${test}*.class" />
397 <target name="base-test">
398 <antcall target="base-test-allclasses" />
399 <antcall target="base-test-singleclass" />
402 <!-- Run junit test -->
405 <antcall target="base-test">
406 <param name="testedclasses" value="${module.classes.dir}" />
410 <!-- reporting target used by other targets. This should not depend on
411 the test target to avoid unnecessary duplicate runs of the tests -->
413 <target name="base-reports" depends="init">
414 <mkdir dir="${module.report.dir}/html" />
415 <mkdir dir="${module.report.dir}/html/unit" />
416 <junitreport todir="${module.report.dir}" tofile="${unitreport}">
417 <fileset dir="${module.report.dir}">
418 <include name="TEST-*.xml" />
420 <report todir="${module.report.dir}/html/unit" />
424 <!-- Run junit tests with HTML reporting -->
426 <target name="junit-reports" depends="test">
427 <antcall target="base-reports" />
428 <antcall target="emma-reports" />
431 <target name="reports">
432 <antcall target="junit-reports">
433 <param name="emma.enabled" value="true"/>
437 <!-- Instrument classes using emma -->
439 <target name="emma" depends="init_directory_properties">
440 <emma enabled="${emma.enabled}">
441 <instr instrpath="${module.classes.dir}" mode="overwrite"/>
445 <target name="emma-reports" depends="init_directory_properties" if="emma.enabled">
446 <mkdir dir="${module.emmareport.dir}"/>
447 <emma enabled="${emma.enabled}" >
448 <report sourcepath="${module.source.dir}">
449 <!-- collect all EMMA data dumps (metadata and runtime): -->
450 <infileset dir="." includes="*.em, *.ec" />
452 <txt outfile="${module.emmareport.dir}/report.txt"/>
453 <html outfile="${module.emmareport.dir}/index.html"/>
455 <dirset dir="${src}" >
464 <!-- ============================================================================
466 ============================================================================ -->
468 <!-- Runs a main program found in the test source tree.
470 - my.test.program: class name of the program to run
471 - my.args: arguments to be passed to the program -->
472 <target name="runTestProgram" depends="testclasses">
473 <java classname="${my.test.program}">
474 <arg line="${my.args}"/>
476 <path refid="xmlschemas.path" />
477 <path refid="junit.path" />
478 <pathelement path="${module.testclasses.dir}" />
479 <pathelement path="${testedclasses}" />
480 <pathelement path="${testlibrary}" />
481 <pathelement path="${module.classes.dir}" />
482 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
483 <!-- the test resource directory is added to the path as well to make it
484 easy to access resources from tests -->
485 <pathelement path="${module.testresource.dir}" />
486 <path refid="module.testbuild.path" />
487 <path refid="module.build.path" />
492 <property name="database.starter"
493 value="org.wamblee.persistence.test.DatabaseStarter"/>
494 <target name="startdb">
495 <echo>After the database has started, you must populate the database in some way.
496 For instance, using the schemaupdate ant target</echo>
497 <antcall target="runTestProgram">
498 <param name="my.test.program" value="${database.starter}"/>
499 <param name="my.args" value=""/>
503 <property name="schemaupdater"
504 value="org.wamblee.test.HibernateUtils"/>
505 <target name="schemaupdate">
506 <antcall target="runTestProgram">
507 <param name="my.test.program" value="${schemaupdater}"/>
508 <param name="my.args" value="${hibernate.filelist}"/>
512 <target name="schemaexport" depends="init">
513 <mkdir dir="${module.sql.dir}" />
514 <echo>Generating schema in output file ${module.sql.dir}/hibernate.sql</echo>
515 <antcall target="runTestProgram">
516 <param name="my.test.program" value="${schemaupdater}"/>
517 <param name="my.args" value="-export ${module.sql.dir}/hibernate.sql ${hibernate.filelist}"/>
521 <!-- INCLUDED MARKER -->
522 <property name="build_trailer_included" value="true" />