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" />
175 <echo>Result is available in ${module.pdfdoc.dir}"</echo>
178 <!-- ============================================================================
180 ============================================================================ -->
182 <target name="doccheck" depends="init">
183 <mkdir dir="${module.doccheck.dir}" />
184 <javadoc packagenames="*" destdir="${module.doccheck.dir}"
185 author="true" version="true"
186 doclet="com.sun.tools.doclets.doccheck.DocCheck"
187 docletpathref="doccheck.path"
188 classpath="${module.classpath}"
189 sourcepath="${module.source.dir}">
191 <echo>Results are available in ${module.doccheck.dir}"</echo>
194 <!-- ============================================================================
195 Copy build results to a standard location.
196 ============================================================================ -->
198 <target name="clean-dist" depends="clean">
200 <fileset dir="${module.dist.dir}" includes="**"/>
204 <target name="dist-lite-product" depends="deps,jar">
205 <mkdir dir="${module.dist.dir}"/>
207 <fileset dir="${module.dist.dir}" excludes="**/CVS" />
209 <copy todir="${module.dist.dir}" flatten="yes">
210 <fileset dir="${module.build.dir}">
211 <include name="**/*.jar" />
213 <fileset dir="${module.build.dir}">
214 <include name="**/*.pdf" />
219 <target name="dist-lite-test" depends="deps,testclasses">
220 <jar destfile="${module.dist.dir}/${module.testjar.name}"
221 basedir="${module.testclasses.dir}"
222 includes="**/*.class"/>
223 <jar destfile="${module.dist.dir}/${module.testresourcesjar.name}"
224 basedir="${module.testresource.dir}" />
227 <target name="dist-lite" depends="clean,dist-lite-product,dist-lite-test">
230 <target name="dist-javadoc" depends="javadoc,pdfdoc,testjavadoc">
231 <jar destfile="${module.dist.dir}/${module.javadocjar.name}"
232 basedir="${module.javadoc.dir}" />
233 <jar destfile="${module.dist.dir}/${module.testjavadocjar.name}"
234 basedir="${module.testjavadoc.dir}" />
235 <copy todir="${module.api.forrest.dir}">
236 <fileset dir="${module.javadoc.dir}" />
241 depends="dist-lite,dist-javadoc"
242 description="copying compiled sources to dist location and copy documentation to forrest site">
244 message="Copying build results for ${module.name} to a location where other modules can find it." />
247 <!-- ============================================================================
249 ============================================================================ -->
251 <target name="checkstyle-impl">
252 <checkstyle config="${build.dir}/${checkstyle.rules}"
253 failOnViolation="false">
255 <pathelement path="${checkstyle.classpath}"/>
257 <fileset dir="${checkstyle.srcdir}" includes="**/*.java"/>
258 <formatter type="xml" tofile="${module.checkstyle.dir}/${checkstyle.report}.xml"/>
260 <style style="${build.dir}/checkstyle-simple.xsl"
261 in="${module.checkstyle.dir}/${checkstyle.report}.xml"
262 out="${module.checkstyle.dir}/${checkstyle.report}.html"/>
263 <echo>Results are available at ${module.checkstyle.dir}/${checkstyle.report}.html</echo>
266 <target name="checkstyle" depends="testclasses">
267 <mkdir dir="${module.checkstyle.dir}"/>
268 <antcall target="checkstyle-impl">
269 <param name="checkstyle.classpath" refid="module.build.path"/>
270 <param name="checkstyle.srcdir" value="${module.source.dir}"/>
271 <param name="checkstyle.report" value="source-results"/>
273 <antcall target="checkstyle-impl">
274 <param name="checkstyle.classpath" refid="module.testbuild.path"/>
275 <param name="checkstyle.srcdir" value="${module.test.dir}"/>
276 <param name="checkstyle.report" value="test-results"/>
280 <!-- ============================================================================
281 Formatting source code.
282 ============================================================================ -->
283 <target name="format" depends="init">
284 <jalopy loglevel="INFO" classpathref="module.testbuild.path"
285 convention="${jalopy.rules}">
286 <fileset dir="${module.source.dir}">
287 <include name="**/*.java" />
289 <fileset dir="${module.test.dir}">
290 <include name="**/*.java" />
295 <!-- =========================================================================
296 Check redundancy in the code
297 ========================================================================= -->
298 <target name="simian" depends="init">
299 <simian threshold="7">
300 <fileset dir="${module.source.dir}" includes="**/*.java" />
305 <!-- =========================================================================
306 Check dependencies using macker.
307 ========================================================================= -->
308 <property name="macker.file" value="macker.xml" />
309 <target name="macker" depends="compile">
310 <available file="${macker.file}" property="macker.file.found" />
311 <fail message="Macker source file ${macker.file} was not found."
312 unless="macker.file.found" />
314 <rules dir="." includes="macker.xml" />
315 <classes dir="${module.classes.dir}">
316 <include name="**/*.class" />
319 <pathelement path="${module.classes.dir}" />
320 <path refid="module.build.path" />
326 <!-- ===========================================================================
328 =========================================================================== -->
330 <target name="testclasses" depends="compile">
331 <mkdir dir="${module.test.dir}" />
332 <mkdir dir="${module.testresource.dir}" />
333 <mkdir dir="${module.testclasses.dir}" />
334 <path id="test.classpath">
335 <pathelement path="${module.classes.dir}" />
336 <pathelement path="${module.test.dir}" />
337 <path refid="module.testbuild.path" />
338 <path refid="module.build.path" />
340 <javac srcdir="${module.test.dir}"
341 destdir="${module.testclasses.dir}"
342 debug="${javac.debug}" debuglevel="${javac.debug.level}" compiler="modern"
343 source="${javac.source}" failonerror="yes">
345 <path refid="test.classpath"/>
348 <copy todir="${module.testclasses.dir}">
349 <fileset dir="${module.test.dir}" excludes="**/*.java" />
350 <fileset dir="${module.testresource.dir}" />
354 <!-- test-base is a target mean to be used by other targets.
355 It expects one parameter names 'testedclasses' to indicate the directory
356 where the compiled test classes reside.
359 <target name="base-test-clean">
360 <delete file="coverage.ec"/>
361 <delete file="coverage.em"/>
365 <target name="base-test-impl" depends="testclasses">
366 <mkdir dir="${module.report.dir}" />
367 <antcall target="emma"/>
368 <junit haltonfailure="${junit.halt.on.failure}" printsummary="on" dir="." fork="yes" showoutput="yes">
369 <batchtest todir="${module.report.dir}">
370 <fileset dir="${module.testclasses.dir}">
371 <include name="${testclassnames}" />
372 <!-- exclude inner classes -->
373 <exclude name="**/*$$*.class"/>
376 <formatter type="xml" />
378 <path refid="xmlschemas.path" />
379 <pathelement path="${module.testclasses.dir}" />
380 <pathelement path="${testedclasses}" />
381 <pathelement path="${testlibrary}" />
382 <pathelement path="${module.classes.dir}" />
383 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
384 <!-- the test resource directory is added to the path as well to make it
385 easy to access resources from tests -->
386 <pathelement path="${module.testresource.dir}" />
387 <path refid="module.testbuild.path" />
388 <path refid="module.build.path" />
393 <target name="base-test-allclasses" unless="test">
394 <echo>Testing all classes</echo>
395 <antcall target="base-test-impl">
396 <param name="testclassnames" value="**/*Test.class" />
400 <target name="base-test-singleclass" if="test">
401 <echo>Testing testcases that conform to the pattern *${test}*</echo>
402 <antcall target="base-test-impl">
403 <param name="testclassnames" value="**/*${test}*.class" />
407 <target name="base-test">
408 <antcall target="base-test-allclasses" />
409 <antcall target="base-test-singleclass" />
412 <!-- Run junit test -->
415 <antcall target="base-test">
416 <param name="testedclasses" value="${module.classes.dir}" />
420 <!-- reporting target used by other targets. This should not depend on
421 the test target to avoid unnecessary duplicate runs of the tests -->
423 <target name="base-reports" depends="init">
424 <mkdir dir="${module.report.dir}/html" />
425 <mkdir dir="${module.report.dir}/html/unit" />
426 <junitreport todir="${module.report.dir}" tofile="${unitreport}">
427 <fileset dir="${module.report.dir}">
428 <include name="TEST-*.xml" />
430 <report todir="${module.report.dir}/html/unit" />
434 <!-- Run junit tests with HTML reporting -->
436 <target name="junit-reports" depends="test">
437 <antcall target="base-reports" />
438 <antcall target="emma-reports" />
441 <target name="reports">
442 <antcall target="junit-reports">
443 <param name="emma.enabled" value="true"/>
447 <!-- Instrument classes using emma -->
449 <target name="emma" depends="init_directory_properties">
450 <emma enabled="${emma.enabled}">
451 <instr instrpath="${module.classes.dir}" mode="overwrite"/>
455 <target name="emma-reports" depends="init_directory_properties" if="emma.enabled">
456 <mkdir dir="${module.emmareport.dir}"/>
457 <emma enabled="${emma.enabled}" >
458 <report sourcepath="${module.source.dir}">
459 <!-- collect all EMMA data dumps (metadata and runtime): -->
460 <infileset dir="." includes="*.em, *.ec" />
462 <txt outfile="${module.emmareport.dir}/report.txt"/>
463 <html outfile="${module.emmareport.dir}/index.html"/>
465 <dirset dir="${src}" >
474 <!-- ============================================================================
476 ============================================================================ -->
478 <!-- Runs a main program found in the test source tree.
480 - my.test.program: class name of the program to run
481 - my.args: arguments to be passed to the program -->
482 <target name="runTestProgram" depends="testclasses">
483 <java classname="${my.test.program}">
484 <arg line="${my.args}"/>
486 <path refid="xmlschemas.path" />
487 <path refid="junit.path" />
488 <pathelement path="${module.testclasses.dir}" />
489 <pathelement path="${testedclasses}" />
490 <pathelement path="${testlibrary}" />
491 <pathelement path="${module.classes.dir}" />
492 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
493 <!-- the test resource directory is added to the path as well to make it
494 easy to access resources from tests -->
495 <pathelement path="${module.testresource.dir}" />
496 <path refid="module.testbuild.path" />
497 <path refid="module.build.path" />
502 <property name="database.starter"
503 value="org.wamblee.persistence.test.DatabaseStarter"/>
504 <target name="startdb">
505 <echo>After the database has started, you must populate the database in some way.
506 For instance, using the schemaupdate ant target</echo>
507 <antcall target="runTestProgram">
508 <param name="my.test.program" value="${database.starter}"/>
509 <param name="my.args" value=""/>
513 <property name="schemaupdater"
514 value="org.wamblee.test.HibernateUtils"/>
515 <target name="schemaupdate">
516 <antcall target="runTestProgram">
517 <param name="my.test.program" value="${schemaupdater}"/>
518 <param name="my.args" value="${hibernate.filelist}"/>
522 <target name="schemaexport" depends="init">
523 <mkdir dir="${module.sql.dir}" />
524 <echo>Generating schema in output file ${module.sql.dir}/hibernate.sql</echo>
525 <antcall target="runTestProgram">
526 <param name="my.test.program" value="${schemaupdater}"/>
527 <param name="my.args" value="-export ${module.sql.dir}/hibernate.sql ${hibernate.filelist}"/>
531 <!-- INCLUDED MARKER -->
532 <property name="build_trailer_included" value="true" />