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}" />
59 <delete dir="${module.build.dir}"/>
62 <target name="clean-deps" depends="init_directory_properties">
64 <fileset dir="${external.lib.dir}" includes="*"/>
67 <fileset dir="${test.lib.dir}" includes="*"/>
70 <fileset dir="${ant.downloaded.lib.dir}" includes="*"/>
74 <!-- ============================================================================
75 Compilation of java code.
76 ============================================================================ -->
78 <!-- Compilation of java code, requires a srcdirs variable to be
79 set to a path of one of more directories separated by : or ;
81 <target name="compile-impl" depends="init">
82 <mkdir dir="${module.classes.dir}" />
83 <echo level="info" message="compile ${module.name}, source dirs ${srcdirs}" />
84 <javac srcdir="${srcdirs}" source="${javac.source}"
85 destdir="${module.classes.dir}" classpath="${module.classpath}"
86 debug="${javac.debug}" debuglevel="${javac.debug.level}" />
87 <copy todir="${module.classes.dir}">
88 <fileset dir="${module.source.dir}" excludes="**/*.java" />
92 <!-- Compilation of regular source code -->
93 <target name="compile-src" unless="ejbsource.available" depends="init">
94 <antcall target="compile-impl">
95 <param name="srcdirs" value="${module.source.dir}"/>
99 <!-- Compilation of regular source code and generated source code
101 <target name="compile-src-ejb" if="ejbsource.available" depends="init">
102 <antcall target="compile-impl">
103 <param name="srcdirs" value="${module.source.dir}:${module.ejbsource.dir}"/>
107 <target name="compile" depends="init">
108 <available file="${module.ejbsource.dir}" type="dir" property="ejbsource.available"/>
109 <antcall target="compile-src"/>
110 <antcall target="compile-src-ejb"/>
113 <!-- ============================================================================
114 Generating a jar file.
115 ============================================================================ -->
117 <target name="jar" depends="compile">
118 <mkdir dir="${module.jars.dir}" />
119 <echo level="info" message="jar cdmvbase ${module.name}" />
120 <!-- Hack: how to remove the schemas directory from the jar when it does not exist -->
121 <mkdir dir="${xmlschemas.dir}" />
122 <jar jarfile="${module.jars.dir}/${module.jar.name}"
123 compress="${jarcompress}">
124 <fileset dir="${module.classes.dir}" />
125 <fileset dir="${xmlschemas.dir}" />
130 <!-- ============================================================================
132 ============================================================================ -->
134 <target name="javadoc" depends="init">
135 <!-- create javadocs -->
136 <javadoc packagenames="*" destdir="${module.javadoc.dir}"
137 author="true" version="true" use="true" private="yes"
138 windowtitle="Dragon documentation" source="${javac.source}"
139 sourcepath="${module.source.dir}"
140 classpath="${module.classpath}">
141 <arg value="-docfilessubdirs"/>
142 <arg value="-overview"/>
143 <arg value="${module.source.dir}/overview.html"/>
147 <target name="testjavadoc" depends="testclasses">
148 <!-- create javadocs -->
149 <javadoc packagenames="*" destdir="${module.testjavadoc.dir}"
150 author="true" version="true" use="true" private="yes"
151 windowtitle="Dragon test documentation" source="${javac.source}"
152 sourcepath="${module.test.dir}"
153 classpathref="test.classpath">
157 <!-- ============================================================================
158 Generate javadoc in pdf format
159 ============================================================================ -->
161 <target name="pdfdoc" depends="init">
162 <!-- create javadocs -->
163 <mkdir dir="${module.pdfdoc.dir}" />
164 <javadoc packagenames="*" author="true" version="true" private="yes"
165 source="${javac.source}" doclet="com.tarsec.javadoc.pdfdoclet.PDFDoclet"
166 docletpathref="pdfdoclet.path"
167 classpath="${module.classpath}"
168 sourcepath="${module.source.dir}"
169 additionalparam="-pdf ${module.pdfdoc.dir}/${module.name}.pdf">
170 <!-- fileset dir="${module.source.dir}">
171 <include name="**/*.java" />
175 message="Unfortuantely, this target will have generated some errors but the pdf will still look fine" />
176 <echo>Result is available in ${module.pdfdoc.dir}"</echo>
179 <!-- ============================================================================
181 ============================================================================ -->
183 <target name="doccheck" depends="init">
184 <mkdir dir="${module.doccheck.dir}" />
185 <javadoc packagenames="*" destdir="${module.doccheck.dir}"
186 author="true" version="true"
187 doclet="com.sun.tools.doclets.doccheck.DocCheck"
188 docletpathref="doccheck.path"
189 classpath="${module.classpath}"
190 sourcepath="${module.source.dir}">
192 <echo>Results are available in ${module.doccheck.dir}"</echo>
195 <!-- ============================================================================
196 Copy build results to a standard location.
197 ============================================================================ -->
199 <target name="clean-dist" depends="clean">
201 <fileset dir="${module.dist.dir}" includes="**"/>
205 <target name="dist-lite-product" depends="deps,jar">
206 <mkdir dir="${module.dist.dir}"/>
208 <fileset dir="${module.dist.dir}" excludes="**/CVS" />
210 <copy todir="${module.dist.dir}" flatten="yes">
211 <fileset dir="${module.build.dir}">
212 <include name="**/*.jar" />
214 <fileset dir="${module.build.dir}">
215 <include name="**/*.pdf" />
220 <target name="dist-lite-test" depends="deps,testclasses">
221 <jar destfile="${module.dist.dir}/${module.testjar.name}"
222 basedir="${module.testclasses.dir}"
223 includes="**/*.class"/>
224 <jar destfile="${module.dist.dir}/${module.testresourcesjar.name}"
225 basedir="${module.testresource.dir}" />
228 <target name="dist-lite" depends="clean,dist-lite-product,dist-lite-test">
230 <isset property="post-dist-lite"/>
232 <antcall target="post-dist-lite"/>
237 <target name="dist-javadoc" depends="javadoc,pdfdoc,testjavadoc">
238 <jar destfile="${module.dist.dir}/${module.javadocjar.name}"
239 basedir="${module.javadoc.dir}" />
240 <jar destfile="${module.dist.dir}/${module.testjavadocjar.name}"
241 basedir="${module.testjavadoc.dir}" />
242 <copy todir="${module.api.forrest.dir}">
243 <fileset dir="${module.javadoc.dir}" />
248 depends="dist-lite,dist-javadoc"
249 description="copying compiled sources to dist location and copy documentation to forrest site">
251 message="Copying build results for ${module.name} to a location where other modules can find it." />
254 <!-- ============================================================================
256 ============================================================================ -->
258 <target name="checkstyle-impl">
259 <checkstyle config="${build.dir}/${checkstyle.rules}"
260 failOnViolation="false">
262 <pathelement path="${checkstyle.classpath}"/>
264 <fileset dir="${checkstyle.srcdir}" includes="**/*.java"/>
265 <formatter type="xml" tofile="${module.checkstyle.dir}/${checkstyle.report}.xml"/>
267 <style style="${build.dir}/checkstyle-simple.xsl"
268 in="${module.checkstyle.dir}/${checkstyle.report}.xml"
269 out="${module.checkstyle.dir}/${checkstyle.report}.html"/>
270 <echo>Results are available at ${module.checkstyle.dir}/${checkstyle.report}.html</echo>
273 <target name="checkstyle" depends="testclasses">
274 <mkdir dir="${module.checkstyle.dir}"/>
275 <antcall target="checkstyle-impl">
276 <param name="checkstyle.classpath" refid="module.build.path"/>
277 <param name="checkstyle.srcdir" value="${module.source.dir}"/>
278 <param name="checkstyle.report" value="source-results"/>
280 <antcall target="checkstyle-impl">
281 <param name="checkstyle.classpath" refid="module.testbuild.path"/>
282 <param name="checkstyle.srcdir" value="${module.test.dir}"/>
283 <param name="checkstyle.report" value="test-results"/>
287 <!-- ============================================================================
288 Formatting source code.
289 ============================================================================ -->
290 <target name="format" depends="init">
291 <jalopy loglevel="INFO" classpathref="module.testbuild.path"
292 convention="${jalopy.rules}">
293 <fileset dir="${module.source.dir}">
294 <include name="**/*.java" />
296 <fileset dir="${module.test.dir}">
297 <include name="**/*.java" />
302 <!-- =========================================================================
303 Check redundancy in the code
304 ========================================================================= -->
305 <target name="simian" depends="init">
306 <simian threshold="7">
307 <fileset dir="${module.source.dir}" includes="**/*.java" />
312 <!-- =========================================================================
313 Check dependencies using macker.
314 ========================================================================= -->
315 <property name="macker.file" value="macker.xml" />
316 <target name="macker" depends="compile">
317 <available file="${macker.file}" property="macker.file.found" />
318 <fail message="Macker source file ${macker.file} was not found."
319 unless="macker.file.found" />
321 <rules dir="." includes="macker.xml" />
322 <classes dir="${module.classes.dir}">
323 <include name="**/*.class" />
326 <pathelement path="${module.classes.dir}" />
327 <path refid="module.build.path" />
333 <!-- ===========================================================================
335 =========================================================================== -->
337 <target name="testclasses" depends="compile">
338 <mkdir dir="${module.test.dir}" />
339 <mkdir dir="${module.testresource.dir}" />
340 <mkdir dir="${module.testclasses.dir}" />
341 <path id="test.classpath">
342 <pathelement path="${module.classes.dir}" />
343 <pathelement path="${module.test.dir}" />
344 <path refid="module.testbuild.path" />
345 <path refid="module.build.path" />
347 <javac srcdir="${module.test.dir}"
348 destdir="${module.testclasses.dir}"
349 debug="${javac.debug}" debuglevel="${javac.debug.level}" compiler="modern"
350 source="${javac.source}" failonerror="yes">
352 <path refid="test.classpath"/>
355 <copy todir="${module.testclasses.dir}">
356 <fileset dir="${module.test.dir}" excludes="**/*.java" />
357 <fileset dir="${module.testresource.dir}" />
361 <!-- test-base is a target mean to be used by other targets.
362 It expects one parameter names 'testedclasses' to indicate the directory
363 where the compiled test classes reside.
366 <target name="base-test-clean">
367 <delete file="coverage.ec"/>
368 <delete file="coverage.em"/>
372 <target name="base-test-impl" depends="testclasses">
373 <mkdir dir="${module.report.dir}" />
374 <antcall target="emma"/>
375 <junit haltonfailure="${junit.halt.on.failure}" printsummary="on" dir="." fork="yes" showoutput="yes">
376 <batchtest todir="${module.report.dir}">
377 <fileset dir="${module.testclasses.dir}">
378 <include name="${testclassnames}" />
379 <!-- exclude inner classes -->
380 <exclude name="**/*$$*.class"/>
383 <formatter type="xml" />
385 <path refid="xmlschemas.path" />
386 <pathelement path="${module.testclasses.dir}" />
387 <pathelement path="${testedclasses}" />
388 <pathelement path="${testlibrary}" />
389 <pathelement path="${module.classes.dir}" />
390 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
391 <!-- the test resource directory is added to the path as well to make it
392 easy to access resources from tests -->
393 <pathelement path="${module.testresource.dir}" />
394 <path refid="module.testbuild.path" />
395 <path refid="module.build.path" />
400 <target name="base-test-allclasses" unless="test">
401 <echo>Testing all classes</echo>
402 <antcall target="base-test-impl">
403 <param name="testclassnames" value="**/*Test.class" />
407 <target name="base-test-singleclass" if="test">
408 <echo>Testing testcases that conform to the pattern *${test}*</echo>
409 <antcall target="base-test-impl">
410 <param name="testclassnames" value="**/*${test}*.class" />
414 <target name="base-test">
415 <antcall target="base-test-allclasses" />
416 <antcall target="base-test-singleclass" />
419 <!-- Run junit test -->
422 <antcall target="base-test">
423 <param name="testedclasses" value="${module.classes.dir}" />
427 <!-- reporting target used by other targets. This should not depend on
428 the test target to avoid unnecessary duplicate runs of the tests -->
430 <target name="base-reports" depends="init">
431 <mkdir dir="${module.report.dir}/html" />
432 <mkdir dir="${module.report.dir}/html/unit" />
433 <junitreport todir="${module.report.dir}" tofile="${unitreport}">
434 <fileset dir="${module.report.dir}">
435 <include name="TEST-*.xml" />
437 <report todir="${module.report.dir}/html/unit" />
441 <!-- Run junit tests with HTML reporting -->
443 <target name="junit-reports" depends="test">
444 <antcall target="base-reports" />
445 <antcall target="emma-reports" />
448 <target name="reports">
449 <antcall target="junit-reports">
450 <param name="emma.enabled" value="true"/>
454 <!-- Instrument classes using emma -->
456 <target name="emma" depends="init_directory_properties">
457 <emma enabled="${emma.enabled}">
458 <instr instrpath="${module.classes.dir}" mode="overwrite"/>
462 <target name="emma-reports" depends="init_directory_properties" if="emma.enabled">
463 <mkdir dir="${module.emmareport.dir}"/>
464 <emma enabled="${emma.enabled}" >
465 <report sourcepath="${module.source.dir}">
466 <!-- collect all EMMA data dumps (metadata and runtime): -->
467 <infileset dir="." includes="*.em, *.ec" />
469 <txt outfile="${module.emmareport.dir}/report.txt"/>
470 <html outfile="${module.emmareport.dir}/index.html"/>
472 <dirset dir="${src}" >
480 <!-- =======================================================================
482 ======================================================================-->
483 <target name="forrest" description="runs Forrest">
484 <property name="forrest.home" location="${env.FORREST_HOME}" />
485 <property name="forrest.ant.home" location="${forrest.home}/tools/ant" />
486 <java classname="org.apache.tools.ant.Main" fork="true" failonerror="true" maxmemory="128M">
488 <fileset dir="${forrest.ant.home}/lib">
489 <include name="*.jar" />
491 <pathelement path="${java.home}/../lib/tools.jar" />
493 <sysproperty key="ant.home" value="${forrest.ant.home}" />
494 <sysproperty key="forrest.home" value="${forrest.home}" />
495 <sysproperty key="basedir" value="${basedir}" />
496 <sysproperty key="java.endorsed.dirs" value="${forrest.home}/lib/endorsed" />
497 <arg line="-f ${forrest.home}/main/forrest.build.xml" />
501 <!-- ============================================================================
503 ============================================================================ -->
505 <!-- Runs a main program found in the test source tree.
507 - my.test.program: class name of the program to run
508 - my.args: arguments to be passed to the program -->
509 <target name="runTestProgram" depends="testclasses">
510 <java classname="${my.test.program}">
511 <arg line="${my.args}"/>
513 <path refid="xmlschemas.path" />
514 <path refid="junit.path" />
515 <pathelement path="${module.testclasses.dir}" />
516 <pathelement path="${testedclasses}" />
517 <pathelement path="${testlibrary}" />
518 <pathelement path="${module.classes.dir}" />
519 <pathelement path="${log4j.properties.dir}" /><!-- for log4j.properties -->
520 <!-- the test resource directory is added to the path as well to make it
521 easy to access resources from tests -->
522 <pathelement path="${module.testresource.dir}" />
523 <path refid="module.testbuild.path" />
524 <path refid="module.build.path" />
529 <property name="database.starter"
530 value="org.wamblee.persistence.test.DatabaseStarter"/>
531 <target name="startdb">
532 <echo>After the database has started, you must populate the database in some way.
533 For instance, using the schemaupdate ant target</echo>
534 <antcall target="runTestProgram">
535 <param name="my.test.program" value="${database.starter}"/>
536 <param name="my.args" value=""/>
540 <property name="schemaupdater"
541 value="org.wamblee.test.HibernateUtils"/>
542 <target name="schemaupdate">
543 <antcall target="runTestProgram">
544 <param name="my.test.program" value="${schemaupdater}"/>
545 <param name="my.args" value="${hibernate.filelist}"/>
549 <target name="schemaexport" depends="init">
550 <mkdir dir="${module.sql.dir}" />
551 <echo>Generating schema in output file ${module.sql.dir}/hibernate.sql</echo>
552 <antcall target="runTestProgram">
553 <param name="my.test.program" value="${schemaupdater}"/>
554 <param name="my.args" value="-export ${module.sql.dir}/hibernate.sql ${hibernate.filelist}"/>
558 <!-- INCLUDED MARKER -->
559 <property name="build_trailer_included" value="true" />