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">
62 <delete dir="${external.lib.dir}"/>
63 <mkdir dir="${external.lib.dir}"/>
64 <delete dir="${test.lib.dir}"/>
65 <mkdir dir="${test.lib.dir}"/>
66 <delete dir="${ant.downloaded.lib.dir}"/>
67 <mkdir dir="${ant.downloaded.lib.dir}"/>
70 <!-- ============================================================================
71 Compilation of java code.
72 ============================================================================ -->
74 <!-- Compilation of java code, requires a srcdirs variable to be
75 set to a path of one of more directories separated by : or ;
77 <target name="compile-impl" depends="init">
78 <mkdir dir="${module.classes.dir}" />
79 <echo level="info" message="compile ${module.name}, source dirs ${srcdirs}" />
80 <javac srcdir="${srcdirs}" source="${javac.source}"
81 destdir="${module.classes.dir}" classpath="${module.classpath}"
82 debug="${javac.debug}" debuglevel="${javac.debug.level}" />
83 <copy todir="${module.classes.dir}">
84 <fileset dir="${module.source.dir}" excludes="**/*.java" />
88 <!-- Compilation of regular source code -->
89 <target name="compile-src" unless="ejbsource.available" depends="init">
90 <antcall target="compile-impl">
91 <param name="srcdirs" value="${module.source.dir}"/>
95 <!-- Compilation of regular source code and generated source code
97 <target name="compile-src-ejb" if="ejbsource.available" depends="init">
98 <antcall target="compile-impl">
99 <param name="srcdirs" value="${module.source.dir}:${module.ejbsource.dir}"/>
103 <target name="compile" depends="init">
104 <available file="${module.ejbsource.dir}" type="dir" property="ejbsource.available"/>
105 <antcall target="compile-src"/>
106 <antcall target="compile-src-ejb"/>
109 <!-- ============================================================================
110 Generating a jar file.
111 ============================================================================ -->
113 <target name="jar" depends="compile">
114 <mkdir dir="${module.jars.dir}" />
115 <echo level="info" message="jar cdmvbase ${module.name}" />
116 <!-- Hack: how to remove the schemas directory from the jar when it does not exist -->
117 <mkdir dir="${xmlschemas.dir}" />
118 <jar jarfile="${module.jars.dir}/${module.jar.name}"
119 compress="${jarcompress}">
120 <fileset dir="${module.classes.dir}" />
121 <fileset dir="${xmlschemas.dir}" />
126 <!-- ============================================================================
128 ============================================================================ -->
130 <target name="javadoc" depends="init">
131 <!-- create javadocs -->
132 <javadoc packagenames="*" destdir="${module.javadoc.dir}"
133 author="true" version="true" use="true" private="yes"
134 windowtitle="Dragon documentation" source="${javac.source}"
135 sourcepath="${module.source.dir}"
136 classpath="${module.classpath}">
137 <arg value="-docfilessubdirs"/>
138 <arg value="-overview"/>
139 <arg value="${module.source.dir}/overview.html"/>
143 <target name="testjavadoc" depends="testclasses">
144 <!-- create javadocs -->
145 <javadoc packagenames="*" destdir="${module.testjavadoc.dir}"
146 author="true" version="true" use="true" private="yes"
147 windowtitle="Dragon test documentation" source="${javac.source}"
148 sourcepath="${module.test.dir}"
149 classpathref="test.classpath">
153 <!-- ============================================================================
154 Generate javadoc in pdf format
155 ============================================================================ -->
157 <target name="pdfdoc" depends="init">
158 <!-- create javadocs -->
159 <mkdir dir="${module.pdfdoc.dir}" />
160 <javadoc packagenames="*" author="true" version="true" private="yes"
161 source="${javac.source}" doclet="com.tarsec.javadoc.pdfdoclet.PDFDoclet"
162 docletpathref="pdfdoclet.path"
163 classpath="${module.classpath}"
164 sourcepath="${module.source.dir}"
165 additionalparam="-pdf ${module.pdfdoc.dir}/${module.name}.pdf">
166 <!-- fileset dir="${module.source.dir}">
167 <include name="**/*.java" />
171 message="Unfortuantely, this target will have generated some errors but the pdf will still look fine" />
174 <!-- ============================================================================
176 ============================================================================ -->
178 <target name="doccheck" depends="init">
179 <mkdir dir="${module.doccheck.dir}" />
180 <javadoc packagenames="*" destdir="${module.doccheck.dir}"
181 author="true" version="true"
182 doclet="com.sun.tools.doclets.doccheck.DocCheck"
183 docletpathref="doccheck.path"
184 classpath="${module.classpath}"
185 sourcepath="${module.source.dir}">
189 <!-- ============================================================================
190 Copy build results to a standard location.
191 ============================================================================ -->
193 <target name="clean-dist" depends="clean">
195 <fileset dir="${module.dist.dir}" includes="**"/>
199 <target name="dist-lite-product" depends="jar">
200 <mkdir dir="${module.dist.dir}"/>
202 <fileset dir="${module.dist.dir}" excludes="**/CVS" />
204 <copy todir="${module.dist.dir}" flatten="yes">
205 <fileset dir="${module.build.dir}">
206 <include name="**/*.jar" />
208 <fileset dir="${module.build.dir}">
209 <include name="**/*.pdf" />
214 <target name="dist-lite-test" depends="testclasses">
215 <jar destfile="${module.dist.dir}/${module.testjar.name}"
216 basedir="${module.testclasses.dir}"
217 includes="**/*.class"/>
218 <jar destfile="${module.dist.dir}/${module.testresourcesjar.name}"
219 basedir="${module.testresource.dir}" />
222 <target name="dist-lite" depends="clean,dist-lite-product,dist-lite-test">
225 <target name="dist-javadoc" depends="javadoc,pdfdoc,testjavadoc">
226 <jar destfile="${module.dist.dir}/${module.javadocjar.name}"
227 basedir="${module.javadoc.dir}" />
228 <jar destfile="${module.dist.dir}/${module.testjavadocjar.name}"
229 basedir="${module.testjavadoc.dir}" />
230 <copy todir="${module.api.forrest.dir}">
231 <fileset dir="${module.javadoc.dir}" />
236 depends="dist-lite,dist-javadoc"
237 description="copying compiled sources to dist location and copy documentation to forrest site">
239 message="Copying build results for ${module.name} to a location where other modules can find it." />
242 <!-- ============================================================================
244 ============================================================================ -->
246 <target name="checkstyle" depends="testclasses">
247 <checkstyle config="${build.dir}/${checkstyle.rules}"
248 failOnViolation="false">
250 <path refid="module.build.path"/>
252 <fileset dir="${module.source.dir}" includes="**/*.java" />
253 <formatter type="plain" />
256 <checkstyle config="${build.dir}/${checkstyle.test.rules}"
257 failOnViolation="false">
259 <pathelement path="${module.testbuild.path}"/>
261 <fileset dir="${module.test.dir}" includes="**/*.java" />
262 <formatter type="plain" />
267 <!-- ============================================================================
268 Formatting source code.
269 ============================================================================ -->
270 <target name="format" depends="init">
271 <jalopy loglevel="INFO" classpathref="module.testbuild.path"
272 convention="${jalopy.rules}">
273 <fileset dir="${module.source.dir}">
274 <include name="**/*.java" />
276 <fileset dir="${module.test.dir}">
277 <include name="**/*.java" />
282 <!-- =========================================================================
283 Check redundancy in the code
284 ========================================================================= -->
285 <target name="simian" depends="init">
286 <simian threshold="7">
287 <fileset dir="${module.source.dir}" includes="**/*.java" />
292 <!-- =========================================================================
293 Check dependencies using macker.
294 ========================================================================= -->
295 <property name="macker.file" value="macker.xml" />
296 <target name="macker" depends="compile">
297 <available file="${macker.file}" property="macker.file.found" />
298 <fail message="Macker source file ${macker.file} was not found."
299 unless="macker.file.found" />
301 <rules dir="." includes="macker.xml" />
302 <classes dir="${module.classes.dir}">
303 <include name="**/*.class" />
306 <pathelement path="${module.classes.dir}" />
307 <path refid="module.build.path" />
313 <!-- ===========================================================================
315 =========================================================================== -->
317 <target name="testclasses" depends="compile">
318 <mkdir dir="${module.test.dir}" />
319 <mkdir dir="${module.testresource.dir}" />
320 <mkdir dir="${module.testclasses.dir}" />
321 <path id="test.classpath">
322 <pathelement path="${module.classes.dir}" />
323 <pathelement path="${module.test.dir}" />
324 <path refid="module.testbuild.path" />
325 <path refid="module.build.path" />
327 <javac srcdir="${module.test.dir}"
328 destdir="${module.testclasses.dir}"
329 debug="${javac.debug}" debuglevel="${javac.debug.level}" compiler="modern"
330 source="${javac.source}" failonerror="yes">
332 <path refid="test.classpath"/>
335 <copy todir="${module.testclasses.dir}">
336 <fileset dir="${module.test.dir}" excludes="**/*.java" />
337 <fileset dir="${module.testresource.dir}" />
341 <!-- test-base is a target mean to be used by other targets.
342 It expects one parameter names 'testedclasses' to indicate the directory
343 where the compiled test classes reside.
346 <target name="base-test-clean">
347 <delete file="coverage.ec"/>
348 <delete file="coverage.em"/>
352 <target name="base-test-impl" depends="testclasses">
353 <mkdir dir="${module.report.dir}" />
354 <antcall target="emma"/>
355 <junit haltonfailure="${junit.halt.on.failure}" printsummary="on" dir="." fork="yes" showoutput="yes">
356 <batchtest todir="${module.report.dir}">
357 <fileset dir="${module.testclasses.dir}">
358 <include name="${testclassnames}" />
359 <!-- exclude inner classes -->
360 <exclude name="**/*$$*.class"/>
363 <formatter type="xml" />
365 <path refid="xmlschemas.path" />
366 <pathelement path="${module.testclasses.dir}" />
367 <pathelement path="${testedclasses}" />
368 <pathelement path="${testlibrary}" />
369 <pathelement path="${module.classes.dir}" />
370 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
371 <!-- the test resource directory is added to the path as well to make it
372 easy to access resources from tests -->
373 <pathelement path="${module.testresource.dir}" />
374 <path refid="module.testbuild.path" />
375 <path refid="module.build.path" />
380 <target name="base-test-allclasses" unless="test">
381 <echo>Testing all classes</echo>
382 <antcall target="base-test-impl">
383 <param name="testclassnames" value="**/*Test.class" />
387 <target name="base-test-singleclass" if="test">
388 <echo>Testing testcases that conform to the pattern *${test}*</echo>
389 <antcall target="base-test-impl">
390 <param name="testclassnames" value="**/*${test}*.class" />
394 <target name="base-test">
395 <antcall target="base-test-allclasses" />
396 <antcall target="base-test-singleclass" />
399 <!-- Run junit test -->
402 <antcall target="base-test">
403 <param name="testedclasses" value="${module.classes.dir}" />
407 <!-- reporting target used by other targets. This should not depend on
408 the test target to avoid unnecessary duplicate runs of the tests -->
410 <target name="base-reports" depends="init">
411 <mkdir dir="${module.report.dir}/html" />
412 <mkdir dir="${module.report.dir}/html/unit" />
413 <junitreport todir="${module.report.dir}" tofile="${unitreport}">
414 <fileset dir="${module.report.dir}">
415 <include name="TEST-*.xml" />
417 <report todir="${module.report.dir}/html/unit" />
421 <!-- Run junit tests with HTML reporting -->
423 <target name="junit-reports" depends="test">
424 <antcall target="base-reports" />
425 <antcall target="emma-reports" />
428 <target name="reports">
429 <antcall target="junit-reports">
430 <param name="emma.enabled" value="true"/>
434 <!-- Instrument classes using emma -->
436 <target name="emma" depends="init_directory_properties">
437 <emma enabled="${emma.enabled}">
438 <instr instrpath="${module.classes.dir}" mode="overwrite"/>
442 <target name="emma-reports" depends="init_directory_properties" if="emma.enabled">
443 <mkdir dir="${module.emmareport.dir}"/>
444 <emma enabled="${emma.enabled}" >
445 <report sourcepath="${module.source.dir}">
446 <!-- collect all EMMA data dumps (metadata and runtime): -->
447 <infileset dir="." includes="*.em, *.ec" />
449 <txt outfile="${module.emmareport.dir}/report.txt"/>
450 <html outfile="${module.emmareport.dir}/index.html"/>
452 <dirset dir="${src}" >
461 <!-- ============================================================================
463 ============================================================================ -->
465 <!-- Runs a main program found in the test source tree.
467 - my.test.program: class name of the program to run
468 - my.args: arguments to be passed to the program -->
469 <target name="runTestProgram" depends="testclasses">
470 <java classname="${my.test.program}">
471 <arg line="${my.args}"/>
473 <path refid="xmlschemas.path" />
474 <path refid="junit.path" />
475 <pathelement path="${module.testclasses.dir}" />
476 <pathelement path="${testedclasses}" />
477 <pathelement path="${testlibrary}" />
478 <pathelement path="${module.classes.dir}" />
479 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
480 <!-- the test resource directory is added to the path as well to make it
481 easy to access resources from tests -->
482 <pathelement path="${module.testresource.dir}" />
483 <path refid="module.testbuild.path" />
484 <path refid="module.build.path" />
489 <property name="database.starter"
490 value="org.wamblee.persistence.test.DatabaseStarter"/>
491 <target name="startdb">
492 <echo>After the database has started, you must populate the database in some way.
493 For instance, using the schemaupdate ant target</echo>
494 <antcall target="runTestProgram">
495 <param name="my.test.program" value="${database.starter}"/>
496 <param name="my.args" value=""/>
500 <property name="schemaupdater"
501 value="org.wamblee.test.HibernateUtils"/>
502 <target name="schemaupdate">
503 <antcall target="runTestProgram">
504 <param name="my.test.program" value="${schemaupdater}"/>
505 <param name="my.args" value="${hibernate.filelist}"/>
509 <target name="schemaexport" depends="init">
510 <mkdir dir="${module.sql.dir}" />
511 <echo>Generating schema in output file ${module.sql.dir}/hibernate.sql</echo>
512 <antcall target="runTestProgram">
513 <param name="my.test.program" value="${schemaupdater}"/>
514 <param name="my.args" value="-export ${module.sql.dir}/hibernate.sql ${hibernate.filelist}"/>
518 <!-- INCLUDED MARKER -->
519 <property name="build_trailer_included" value="true" />