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="module.test.deps">
44 <param name="download.dir" value="${test.lib.dir}"/>
48 <target name="clean" depends="init_directory_properties,base-test-clean">
49 <delete dir="${module.classes.dir}" />
50 <delete dir="${module.testclasses.dir}" />
51 <delete dir="${module.testoutput.dir}" />
52 <delete dir="${module.jars.dir}" />
53 <delete dir="${module.docbase.dir}" />
54 <delete dir="${module.report.dir}" />
55 <delete dir="${module.sql.dir}" />
58 <target name="clean-deps" depends="init_directory_properties">
59 <delete dir="${external.lib.dir}"/>
60 <delete dir="${test.lib.dir}"/>
63 <!-- ============================================================================
64 Compilation of java code.
65 ============================================================================ -->
67 <!-- Compilation of java code, requires a srcdirs variable to be
68 set to a path of one of more directories separated by : or ;
70 <target name="compile-impl" depends="init">
71 <mkdir dir="${module.classes.dir}" />
72 <echo level="info" message="compile ${module.name}, source dirs ${srcdirs}" />
73 <javac srcdir="${srcdirs}" source="${javac.source}"
74 destdir="${module.classes.dir}" classpath="${module.classpath}"
75 debug="${javac.debug}" debuglevel="${javac.debug.level}" />
76 <copy todir="${module.classes.dir}">
77 <fileset dir="${module.source.dir}" excludes="**/*.java" />
81 <!-- Compilation of regular source code -->
82 <target name="compile-src" unless="ejbsource.available" depends="init">
83 <antcall target="compile-impl">
84 <param name="srcdirs" value="${module.source.dir}"/>
88 <!-- Compilation of regular source code and generated source code
90 <target name="compile-src-ejb" if="ejbsource.available" depends="init">
91 <antcall target="compile-impl">
92 <param name="srcdirs" value="${module.source.dir}:${module.ejbsource.dir}"/>
96 <target name="compile" depends="init">
97 <available file="${module.ejbsource.dir}" type="dir" property="ejbsource.available"/>
98 <antcall target="compile-src"/>
99 <antcall target="compile-src-ejb"/>
102 <!-- ============================================================================
103 Generating a jar file.
104 ============================================================================ -->
106 <target name="jar" depends="compile">
107 <mkdir dir="${module.jars.dir}" />
108 <echo level="info" message="jar cdmvbase ${module.name}" />
109 <!-- Hack: how to remove the schemas directory from the jar when it does not exist -->
110 <mkdir dir="${xmlschemas.dir}" />
111 <jar jarfile="${module.jars.dir}/${module.jar.name}"
112 compress="${jarcompress}">
113 <fileset dir="${module.classes.dir}" />
114 <fileset dir="${xmlschemas.dir}" />
119 <!-- ============================================================================
121 ============================================================================ -->
123 <target name="javadoc" depends="init">
124 <!-- create javadocs -->
125 <javadoc packagenames="*" destdir="${module.javadoc.dir}"
126 author="true" version="true" use="true" private="yes"
127 windowtitle="Dragon documentation" source="${javac.source}"
128 sourcepath="${module.source.dir}"
129 classpath="${module.classpath}">
130 <arg value="-docfilessubdirs"/>
131 <arg value="-overview"/>
132 <arg value="${module.source.dir}/overview.html"/>
136 <target name="testjavadoc" depends="testclasses">
137 <!-- create javadocs -->
138 <javadoc packagenames="*" destdir="${module.testjavadoc.dir}"
139 author="true" version="true" use="true" private="yes"
140 windowtitle="Dragon test documentation" source="${javac.source}"
141 sourcepath="${module.test.dir}"
142 classpathref="test.classpath">
146 <!-- ============================================================================
147 Generate javadoc in pdf format
148 ============================================================================ -->
150 <target name="pdfdoc" depends="init">
151 <!-- create javadocs -->
152 <mkdir dir="${module.pdfdoc.dir}" />
153 <javadoc packagenames="*" author="true" version="true" private="yes"
154 source="${javac.source}" doclet="com.tarsec.javadoc.pdfdoclet.PDFDoclet"
155 docletpathref="pdfdoclet.path"
156 additionalparam="-pdf ${module.pdfdoc.dir}/${module.name}.pdf">
157 <fileset dir="${module.source.dir}">
158 <include name="**/*.java" />
162 message="Unfortuantely, this target will have generated some errors but the pdf will still look fine" />
165 <!-- ============================================================================
167 ============================================================================ -->
169 <target name="doccheck" depends="init">
170 <mkdir dir="${module.doccheck.dir}" />
171 <javadoc packagenames="*" destdir="${module.doccheck.dir}"
172 author="true" version="true"
173 doclet="com.sun.tools.doclets.doccheck.DocCheck"
174 docletpathref="doccheck.path" source="${javac.source}">
175 <fileset dir="${module.source.dir}">
176 <include name="**/*.java" />
181 <!-- ============================================================================
182 Copy build results to a standard location.
183 ============================================================================ -->
185 <target name="clean-dist" depends="clean">
187 <fileset dir="${module.dist.dir}" includes="**"/>
191 <target name="dist-lite-product" depends="jar">
192 <mkdir dir="${module.dist.dir}"/>
194 <fileset dir="${module.dist.dir}" excludes="**/CVS" />
196 <copy todir="${module.dist.dir}" flatten="yes">
197 <fileset dir="${module.build.dir}">
198 <include name="**/*.jar" />
200 <fileset dir="${module.build.dir}">
201 <include name="**/*.pdf" />
206 <target name="dist-lite-test" depends="testclasses">
207 <jar destfile="${module.dist.dir}/${module.testjar.name}"
208 basedir="${module.testclasses.dir}"
209 includes="**/*.class"/>
210 <jar destfile="${module.dist.dir}/${module.testresourcesjar.name}"
211 basedir="${module.testresource.dir}" />
214 <target name="dist-lite" depends="clean,dist-lite-product,dist-lite-test">
217 <target name="dist-javadoc" depends="javadoc,pdfdoc,testjavadoc">
218 <jar destfile="${module.dist.dir}/${module.javadocjar.name}"
219 basedir="${module.javadoc.dir}" />
220 <jar destfile="${module.dist.dir}/${module.testjavadocjar.name}"
221 basedir="${module.testjavadoc.dir}" />
222 <copy todir="${module.api.forrest.dir}">
223 <fileset dir="${module.javadoc.dir}" />
228 depends="dist-lite,dist-javadoc"
229 description="copying compiled sources to dist location and copy documentation to forrest site">
231 message="Copying build results for ${module.name} to a location where other modules can find it." />
234 <!-- ============================================================================
236 ============================================================================ -->
238 <target name="checkstyle" depends="testclasses">
239 <checkstyle config="${build.dir}/${checkstyle.rules}"
240 failOnViolation="false" classpathref="module.testbuild.path">
241 <fileset dir="${module.source.dir}" includes="**/*.java" />
242 <formatter type="plain" />
244 <checkstyle config="${build.dir}/${checkstyle.test.rules}"
245 failOnViolation="false" classpathref="module.testbuild.path">
246 <fileset dir="${module.test.dir}" includes="**/*.java" />
247 <formatter type="plain" />
251 <!-- ============================================================================
252 Formatting source code.
253 ============================================================================ -->
254 <target name="format" depends="init">
255 <jalopy loglevel="INFO" classpathref="module.testbuild.path"
256 convention="${jalopy.rules}">
257 <fileset dir="${module.source.dir}">
258 <include name="**/*.java" />
260 <fileset dir="${module.test.dir}">
261 <include name="**/*.java" />
266 <!-- =========================================================================
267 Check redundancy in the code
268 ========================================================================= -->
269 <target name="simian" depends="init">
270 <simian threshold="7">
271 <fileset dir="${module.source.dir}" includes="**/*.java" />
276 <!-- =========================================================================
277 Check dependencies using macker.
278 ========================================================================= -->
279 <property name="macker.file" value="macker.xml" />
280 <target name="macker" depends="compile">
281 <available file="${macker.file}" property="macker.file.found" />
282 <fail message="Macker source file ${macker.file} was not found."
283 unless="macker.file.found" />
285 <rules dir="." includes="macker.xml" />
286 <classes dir="${module.classes.dir}">
287 <include name="**/*.class" />
290 <pathelement path="${module.classes.dir}" />
291 <path refid="module.build.path" />
297 <!-- ===========================================================================
299 =========================================================================== -->
301 <target name="testclasses" depends="compile">
302 <mkdir dir="${module.test.dir}" />
303 <mkdir dir="${module.testresource.dir}" />
304 <mkdir dir="${module.testclasses.dir}" />
305 <path id="test.classpath">
306 <pathelement path="${module.classes.dir}" />
307 <pathelement path="${module.test.dir}" />
308 <path refid="module.testbuild.path" />
309 <path refid="module.build.path" />
311 <javac srcdir="${module.test.dir}"
312 destdir="${module.testclasses.dir}"
313 debug="${javac.debug}" debuglevel="${javac.debug.level}" compiler="modern"
314 source="${javac.source}" failonerror="yes">
316 <path refid="test.classpath"/>
319 <copy todir="${module.testclasses.dir}">
320 <fileset dir="${module.test.dir}" excludes="**/*.java" />
321 <fileset dir="${module.testresource.dir}" />
325 <!-- test-base is a target mean to be used by other targets.
326 It expects one parameter names 'testedclasses' to indicate the directory
327 where the compiled test classes reside.
330 <target name="base-test-clean">
331 <delete file="coverage.ec"/>
332 <delete file="coverage.em"/>
336 <target name="base-test-impl" depends="testclasses">
337 <mkdir dir="${module.report.dir}" />
338 <antcall target="emma"/>
339 <junit haltonfailure="${junit.halt.on.failure}" printsummary="on" dir="." fork="yes" showoutput="yes">
340 <batchtest todir="${module.report.dir}">
341 <fileset dir="${module.testclasses.dir}">
342 <include name="${testclassnames}" />
343 <!-- exclude inner classes -->
344 <exclude name="**/*$$*.class"/>
347 <formatter type="xml" />
349 <path refid="xmlschemas.path" />
350 <pathelement path="${module.testclasses.dir}" />
351 <pathelement path="${testedclasses}" />
352 <pathelement path="${testlibrary}" />
353 <pathelement path="${module.classes.dir}" />
354 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
355 <!-- the test resource directory is added to the path as well to make it
356 easy to access resources from tests -->
357 <pathelement path="${module.testresource.dir}" />
358 <path refid="module.testbuild.path" />
359 <path refid="module.build.path" />
364 <target name="base-test-allclasses" unless="test">
365 <echo>Testing all classes</echo>
366 <antcall target="base-test-impl">
367 <param name="testclassnames" value="**/*Test.class" />
371 <target name="base-test-singleclass" if="test">
372 <echo>Testing testcases that conform to the pattern *${test}*</echo>
373 <antcall target="base-test-impl">
374 <param name="testclassnames" value="**/*${test}*.class" />
378 <target name="base-test">
379 <antcall target="base-test-allclasses" />
380 <antcall target="base-test-singleclass" />
383 <!-- Run junit test -->
386 <antcall target="base-test">
387 <param name="testedclasses" value="${module.classes.dir}" />
391 <!-- reporting target used by other targets. This should not depend on
392 the test target to avoid unnecessary duplicate runs of the tests -->
394 <target name="base-reports" depends="init">
395 <mkdir dir="${module.report.dir}/html" />
396 <mkdir dir="${module.report.dir}/html/unit" />
397 <junitreport todir="${module.report.dir}" tofile="${unitreport}">
398 <fileset dir="${module.report.dir}">
399 <include name="TEST-*.xml" />
401 <report todir="${module.report.dir}/html/unit" />
405 <!-- Run junit tests with HTML reporting -->
407 <target name="junit-reports" depends="test">
408 <antcall target="base-reports" />
409 <antcall target="emma-reports" />
412 <target name="reports">
413 <antcall target="junit-reports">
414 <param name="emma.enabled" value="true"/>
418 <!-- Instrument classes using emma -->
420 <target name="emma" depends="init_directory_properties">
421 <emma enabled="${emma.enabled}">
422 <instr instrpath="${module.classes.dir}" mode="overwrite"/>
426 <target name="emma-reports" depends="init_directory_properties" if="emma.enabled">
427 <mkdir dir="${module.emmareport.dir}"/>
428 <emma enabled="${emma.enabled}" >
429 <report sourcepath="${module.source.dir}">
430 <!-- collect all EMMA data dumps (metadata and runtime): -->
431 <infileset dir="." includes="*.em, *.ec" />
433 <txt outfile="${module.emmareport.dir}/report.txt"/>
434 <html outfile="${module.emmareport.dir}/index.html"/>
436 <dirset dir="${src}" >
445 <!-- ============================================================================
447 ============================================================================ -->
449 <!-- Runs a main program found in the test source tree.
451 - my.test.program: class name of the program to run
452 - my.args: arguments to be passed to the program -->
453 <target name="runTestProgram" depends="testclasses">
454 <java classname="${my.test.program}">
455 <arg line="${my.args}"/>
457 <path refid="xmlschemas.path" />
458 <path refid="junit.path" />
459 <pathelement path="${module.testclasses.dir}" />
460 <pathelement path="${testedclasses}" />
461 <pathelement path="${testlibrary}" />
462 <pathelement path="${module.classes.dir}" />
463 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
464 <!-- the test resource directory is added to the path as well to make it
465 easy to access resources from tests -->
466 <pathelement path="${module.testresource.dir}" />
467 <path refid="module.testbuild.path" />
468 <path refid="module.build.path" />
473 <property name="database.starter"
474 value="org.wamblee.persistence.test.DatabaseStarter"/>
475 <target name="startdb">
476 <echo>After the database has started, you must populate the database in some way.
477 For instance, using the schemaupdate ant target</echo>
478 <antcall target="runTestProgram">
479 <param name="my.test.program" value="${database.starter}"/>
480 <param name="my.args" value=""/>
484 <property name="schemaupdater"
485 value="org.wamblee.test.HibernateUtils"/>
486 <target name="schemaupdate">
487 <antcall target="runTestProgram">
488 <param name="my.test.program" value="${schemaupdater}"/>
489 <param name="my.args" value="${hibernate.filelist}"/>
493 <target name="schemaexport" depends="init">
494 <mkdir dir="${module.sql.dir}" />
495 <echo>Generating schema in output file ${module.sql.dir}/hibernate.sql</echo>
496 <antcall target="runTestProgram">
497 <param name="my.test.program" value="${schemaupdater}"/>
498 <param name="my.args" value="-export ${module.sql.dir}/hibernate.sql ${hibernate.filelist}"/>
502 <!-- INCLUDED MARKER -->
503 <property name="build_trailer_included" value="true" />