doccheck target now working.
[utils] / build / trailer.xml
1 <!-- PROPERTIES -->
2
3
4 <!-- Default entry point for the build -->
5 <target name="all" depends="clean, init, compile, jar" />
6
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}" />
10   
11   <path id="module.build.path">
12     <fileset dir="${external.lib.dir}">
13       <include name="**/*.jar"/>
14     </fileset>
15   </path>
16   
17   <path id="module.testbuild.path">
18     <fileset dir="${test.lib.dir}">
19       <include name="**/*.jar"/>
20     </fileset>
21   </path>
22
23 </target>
24
25 <target name="init" depends="import_header,startup">
26         <tstamp />
27 </target>
28
29 <!-- ============================================================================
30         Cleanup 
31         ============================================================================ -->
32
33 <target name="ant.deps">
34 </target>
35
36 <target name="deps" depends="import_header">
37   <antcall target="module.build.deps">
38     <param name="download.dir" value="${external.lib.dir}"/>
39   </antcall>
40   <antcall target="test.d">
41     <param name="download.dir" value="${test.lib.dir}"/>
42   </antcall>
43   <antcall target="module.test.deps">
44     <param name="download.dir" value="${test.lib.dir}"/>
45   </antcall>
46 </target>
47
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}" />
56 </target>
57
58 <target name="clean-deps" depends="init_directory_properties">
59   <delete dir="${external.lib.dir}"/>
60   <delete dir="${test.lib.dir}"/>
61 </target>
62
63 <!-- ============================================================================
64         Compilation of java code. 
65         ============================================================================ -->
66
67 <!--  Compilation of java code, requires a srcdirs variable to be
68       set to a path of one of more directories separated by : or ;
69 -->
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" />
78         </copy>
79 </target>
80
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}"/>
85     </antcall>
86 </target>
87
88 <!--  Compilation of regular source code and generated source code
89       for EJBs -->
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}"/>
93     </antcall>
94 </target>
95
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"/>
100 </target>
101
102 <!-- ============================================================================
103         Generating a jar file. 
104         ============================================================================ -->
105
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}" />
115         </jar>
116 </target>
117
118
119 <!-- ============================================================================
120         Generate javadoc.
121         ============================================================================ -->
122
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"/>
133         </javadoc>
134 </target>
135
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">
143         </javadoc>
144 </target>
145
146 <!-- ============================================================================
147         Generate javadoc in pdf format
148         ============================================================================ -->
149
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" />
159                 </fileset>
160         </javadoc>
161         <echo
162                 message="Unfortuantely, this target will have generated some errors but the pdf will still look fine" />
163 </target>
164
165 <!-- ============================================================================
166         Check javadoc
167         ============================================================================ -->
168
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" 
175                 classpath="${module.classpath}"
176                 sourcepath="${module.source.dir}">
177                 <!-- fileset dir="${module.source.dir}">
178                         <include name="**/*.java" />
179                 </fileset -->
180         </javadoc>
181 </target>
182
183 <!-- ============================================================================
184         Copy build results to a standard location. 
185         ============================================================================ -->
186         
187 <target name="clean-dist" depends="clean">
188   <delete>
189     <fileset dir="${module.dist.dir}" includes="**"/>
190   </delete> 
191 </target>
192         
193 <target name="dist-lite-product" depends="jar">
194     <mkdir dir="${module.dist.dir}"/>
195         <delete>
196                 <fileset dir="${module.dist.dir}" excludes="**/CVS" />
197         </delete>
198         <copy todir="${module.dist.dir}" flatten="yes">
199                 <fileset dir="${module.build.dir}">
200                         <include name="**/*.jar" />
201                 </fileset>
202                 <fileset dir="${module.build.dir}">
203                         <include name="**/*.pdf" />
204                 </fileset>
205         </copy>
206 </target>
207
208 <target name="dist-lite-test" depends="testclasses">
209     <jar destfile="${module.dist.dir}/${module.testjar.name}"
210                 basedir="${module.testclasses.dir}" 
211                 includes="**/*.class"/>
212     <jar destfile="${module.dist.dir}/${module.testresourcesjar.name}"
213                 basedir="${module.testresource.dir}" />
214 </target>
215
216 <target name="dist-lite" depends="clean,dist-lite-product,dist-lite-test">
217 </target>
218
219 <target name="dist-javadoc" depends="javadoc,pdfdoc,testjavadoc">
220     <jar destfile="${module.dist.dir}/${module.javadocjar.name}"
221                 basedir="${module.javadoc.dir}" />
222         <jar destfile="${module.dist.dir}/${module.testjavadocjar.name}"
223                 basedir="${module.testjavadoc.dir}" />          
224         <copy todir="${module.api.forrest.dir}">
225                 <fileset dir="${module.javadoc.dir}" />
226         </copy>                         
227 </target>
228
229 <target name="dist"
230         depends="dist-lite,dist-javadoc"
231         description="copying compiled sources to dist location and copy documentation to forrest site">
232         <echo
233                 message="Copying build results for ${module.name} to a location where other modules can find it." />
234 </target>
235
236 <!-- ============================================================================
237         Check style, 
238         ============================================================================ -->
239
240 <target name="checkstyle" depends="testclasses">
241         <checkstyle config="${build.dir}/${checkstyle.rules}"
242                 failOnViolation="false" classpathref="module.testbuild.path">
243                 <fileset dir="${module.source.dir}" includes="**/*.java" />
244                 <formatter type="plain" />
245         </checkstyle>
246         <checkstyle config="${build.dir}/${checkstyle.test.rules}"
247                 failOnViolation="false" classpathref="module.testbuild.path">
248                 <fileset dir="${module.test.dir}" includes="**/*.java" />
249                 <formatter type="plain" />
250         </checkstyle>
251 </target>
252
253 <!-- ============================================================================
254         Formatting source code.  
255         ============================================================================ -->
256 <target name="format" depends="init">
257         <jalopy loglevel="INFO" classpathref="module.testbuild.path"
258                 convention="${jalopy.rules}">
259                 <fileset dir="${module.source.dir}">
260                         <include name="**/*.java" />
261                 </fileset>
262                 <fileset dir="${module.test.dir}">
263                         <include name="**/*.java" />
264                 </fileset>
265         </jalopy>
266 </target>
267
268 <!-- =========================================================================
269         Check redundancy in the code
270         ========================================================================= -->
271 <target name="simian" depends="init">
272         <simian threshold="7">
273                 <fileset dir="${module.source.dir}" includes="**/*.java" />
274         </simian>
275 </target>
276
277
278 <!-- =========================================================================
279         Check dependencies using macker.
280         ========================================================================= -->
281 <property name="macker.file" value="macker.xml" />
282 <target name="macker" depends="compile">
283         <available file="${macker.file}" property="macker.file.found" />
284         <fail message="Macker source file ${macker.file} was not found."
285                 unless="macker.file.found" />
286         <macker>
287                 <rules dir="." includes="macker.xml" />
288                 <classes dir="${module.classes.dir}">
289                         <include name="**/*.class" />
290                 </classes>
291                 <classpath>
292                     <pathelement path="${module.classes.dir}" />
293                         <path refid="module.build.path" />
294                 </classpath>
295         </macker>
296 </target>
297
298
299 <!-- ===========================================================================
300         JUnit tests.
301         =========================================================================== -->
302
303 <target name="testclasses" depends="compile">
304         <mkdir dir="${module.test.dir}" />
305         <mkdir dir="${module.testresource.dir}" />
306         <mkdir dir="${module.testclasses.dir}" />
307                 <path id="test.classpath">
308                 <pathelement path="${module.classes.dir}" />
309                 <pathelement path="${module.test.dir}" />
310                 <path refid="module.testbuild.path" />
311                 <path refid="module.build.path" />
312         </path>
313         <javac srcdir="${module.test.dir}"
314                 destdir="${module.testclasses.dir}" 
315                 debug="${javac.debug}" debuglevel="${javac.debug.level}" compiler="modern"
316                 source="${javac.source}" failonerror="yes">
317                 <classpath>
318                     <path refid="test.classpath"/>
319                 </classpath>
320         </javac>
321         <copy todir="${module.testclasses.dir}">
322                 <fileset dir="${module.test.dir}" excludes="**/*.java" />
323                 <fileset dir="${module.testresource.dir}" />
324         </copy>
325 </target>
326
327 <!-- test-base is a target mean to be used by other targets. 
328         It expects one parameter names 'testedclasses' to indicate the directory
329         where the compiled test classes reside. 
330 -->
331
332 <target name="base-test-clean">
333   <delete file="coverage.ec"/>
334   <delete file="coverage.em"/>
335 </target>
336
337
338 <target name="base-test-impl" depends="testclasses">
339         <mkdir dir="${module.report.dir}" />
340         <antcall target="emma"/>
341         <junit haltonfailure="${junit.halt.on.failure}" printsummary="on" dir="." fork="yes" showoutput="yes">
342                 <batchtest todir="${module.report.dir}">
343                         <fileset dir="${module.testclasses.dir}">
344                                 <include name="${testclassnames}" />
345                                 <!--  exclude inner classes --> 
346                                 <exclude name="**/*$$*.class"/>
347                         </fileset>
348                 </batchtest>
349                 <formatter type="xml" />
350                 <classpath>
351                         <path refid="xmlschemas.path" />
352                         <pathelement path="${module.testclasses.dir}" />
353                         <pathelement path="${testedclasses}" />
354                         <pathelement path="${testlibrary}" />
355                         <pathelement path="${module.classes.dir}" />
356                         <pathelement path="${log4j.properties.dir}" /><!--  for log4j.properties -->
357                         <!-- the test resource directory is added to the path as well to make it
358                                 easy to access resources from tests -->
359                         <pathelement path="${module.testresource.dir}" />
360                         <path refid="module.testbuild.path" />
361                         <path refid="module.build.path" />
362                 </classpath>
363         </junit>
364 </target>
365
366 <target name="base-test-allclasses" unless="test">
367         <echo>Testing all classes</echo>
368         <antcall target="base-test-impl">
369                 <param name="testclassnames" value="**/*Test.class" />
370         </antcall>
371 </target>
372
373 <target name="base-test-singleclass" if="test">
374         <echo>Testing testcases that conform to the pattern *${test}*</echo>
375         <antcall target="base-test-impl">
376                 <param name="testclassnames" value="**/*${test}*.class" />
377         </antcall>
378 </target>
379
380 <target name="base-test">
381         <antcall target="base-test-allclasses" />
382         <antcall target="base-test-singleclass" />
383 </target>
384
385 <!-- Run junit test -->
386
387 <target name="test">
388         <antcall target="base-test">
389                 <param name="testedclasses" value="${module.classes.dir}" />
390         </antcall>
391 </target>
392
393 <!-- reporting target used by other targets. This should not depend on 
394         the test target to avoid unnecessary duplicate runs of the tests -->
395
396 <target name="base-reports" depends="init">
397         <mkdir dir="${module.report.dir}/html" />
398         <mkdir dir="${module.report.dir}/html/unit" />
399         <junitreport todir="${module.report.dir}" tofile="${unitreport}">
400                 <fileset dir="${module.report.dir}">
401                         <include name="TEST-*.xml" />
402                 </fileset>
403                 <report todir="${module.report.dir}/html/unit" />
404         </junitreport>
405 </target>
406
407 <!-- Run junit tests with HTML reporting -->
408
409 <target name="junit-reports" depends="test">
410         <antcall target="base-reports" />
411         <antcall target="emma-reports" />
412 </target>
413
414 <target name="reports">
415   <antcall target="junit-reports">
416     <param name="emma.enabled" value="true"/>
417   </antcall>
418 </target>
419
420  <!-- Instrument classes using emma --> 
421   
422   <target name="emma" depends="init_directory_properties">
423     <emma enabled="${emma.enabled}">
424       <instr instrpath="${module.classes.dir}" mode="overwrite"/>
425     </emma>
426   </target>
427   
428   <target name="emma-reports" depends="init_directory_properties" if="emma.enabled">
429     <mkdir dir="${module.emmareport.dir}"/>
430     <emma enabled="${emma.enabled}" >
431       <report sourcepath="${module.source.dir}">
432         <!-- collect all EMMA data dumps (metadata and runtime): -->
433         <infileset dir="." includes="*.em, *.ec" />
434
435         <txt outfile="${module.emmareport.dir}/report.txt"/>
436         <html outfile="${module.emmareport.dir}/index.html"/>
437         <!-- sourcepath>
438           <dirset dir="${src}" >
439             <include name="." /> 
440           </dirset>
441         </sourcepath -->
442       </report>
443     </emma>
444   </target>
445
446
447 <!--  ============================================================================
448       Database targets
449       ============================================================================ -->
450            
451 <!--  Runs a main program found in the test source tree. 
452       Properties:
453          - my.test.program: class name of the program to run 
454          - my.args: arguments to be passed to the program --> 
455 <target name="runTestProgram" depends="testclasses">
456         <java classname="${my.test.program}">
457             <arg line="${my.args}"/>
458                 <classpath>
459                         <path refid="xmlschemas.path" />
460                         <path refid="junit.path" />
461                         <pathelement path="${module.testclasses.dir}" />
462                         <pathelement path="${testedclasses}" />
463                         <pathelement path="${testlibrary}" />
464                         <pathelement path="${module.classes.dir}" />
465                         <pathelement path="${log4j.properties.dir}" /><!--  for log4j.properties -->
466                         <!-- the test resource directory is added to the path as well to make it
467                                 easy to access resources from tests -->
468                         <pathelement path="${module.testresource.dir}" />
469                         <path refid="module.testbuild.path" />
470                         <path refid="module.build.path" />
471                 </classpath>
472         </java>
473 </target>
474
475 <property name="database.starter" 
476           value="org.wamblee.persistence.test.DatabaseStarter"/>
477 <target name="startdb">
478     <echo>After the database has started, you must populate the database in some way.
479           For instance, using the schemaupdate ant target</echo>
480     <antcall target="runTestProgram">
481         <param name="my.test.program" value="${database.starter}"/>
482         <param name="my.args" value=""/>
483     </antcall>
484 </target>
485
486 <property name="schemaupdater" 
487           value="org.wamblee.test.HibernateUtils"/>
488 <target name="schemaupdate">
489     <antcall target="runTestProgram">
490         <param name="my.test.program" value="${schemaupdater}"/>
491         <param name="my.args" value="${hibernate.filelist}"/>
492     </antcall>
493 </target>
494
495 <target name="schemaexport" depends="init">
496     <mkdir dir="${module.sql.dir}" />
497     <echo>Generating schema in output file ${module.sql.dir}/hibernate.sql</echo>
498     <antcall target="runTestProgram">
499         <param name="my.test.program" value="${schemaupdater}"/>
500         <param name="my.args" value="-export ${module.sql.dir}/hibernate.sql ${hibernate.filelist}"/>
501     </antcall>
502 </target>
503
504 <!-- INCLUDED MARKER -->
505 <property name="build_trailer_included" value="true" />
506
507