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