(no commit message)
[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="ant.d">
44     <param name="download.dir" value="${ant.downloaded.lib.dir}"/>
45   </antcall>
46   <antcall target="module.test.deps">
47     <param name="download.dir" value="${test.lib.dir}"/>
48   </antcall>
49 </target>
50
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 </target>
60
61 <target name="clean-deps" depends="init_directory_properties">
62   <delete>
63     <fileset dir="${external.lib.dir}" includes="*"/>
64   </delete>
65   <delete>
66     <fileset dir="${test.lib.dir}" includes="*"/>
67   </delete>
68   <delete>
69     <fileset dir="${ant.downloaded.lib.dir}" includes="*"/>
70   </delete>
71 </target>
72
73 <!-- ============================================================================
74         Compilation of java code. 
75         ============================================================================ -->
76
77 <!--  Compilation of java code, requires a srcdirs variable to be
78       set to a path of one of more directories separated by : or ;
79 -->
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" />
88         </copy>
89 </target>
90
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}"/>
95     </antcall>
96 </target>
97
98 <!--  Compilation of regular source code and generated source code
99       for EJBs -->
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}"/>
103     </antcall>
104 </target>
105
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"/>
110 </target>
111
112 <!-- ============================================================================
113         Generating a jar file. 
114         ============================================================================ -->
115
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}" />
125         </jar>
126 </target>
127
128
129 <!-- ============================================================================
130         Generate javadoc.
131         ============================================================================ -->
132
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"/>
143         </javadoc>
144 </target>
145
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">
153         </javadoc>
154 </target>
155
156 <!-- ============================================================================
157         Generate javadoc in pdf format
158         ============================================================================ -->
159
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" />
171                 </fileset -->
172         </javadoc>
173         <echo
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>
176 </target>
177
178 <!-- ============================================================================
179         Check javadoc
180         ============================================================================ -->
181
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}">
190         </javadoc>
191         <echo>Results are available in ${module.doccheck.dir}"</echo>
192 </target>
193
194 <!-- ============================================================================
195         Copy build results to a standard location. 
196         ============================================================================ -->
197         
198 <target name="clean-dist" depends="clean">
199   <delete>
200     <fileset dir="${module.dist.dir}" includes="**"/>
201   </delete> 
202 </target>
203         
204 <target name="dist-lite-product" depends="deps,jar">
205     <mkdir dir="${module.dist.dir}"/>
206         <delete>
207                 <fileset dir="${module.dist.dir}" excludes="**/CVS" />
208         </delete>
209         <copy todir="${module.dist.dir}" flatten="yes">
210                 <fileset dir="${module.build.dir}">
211                         <include name="**/*.jar" />
212                 </fileset>
213                 <fileset dir="${module.build.dir}">
214                         <include name="**/*.pdf" />
215                 </fileset>
216         </copy>
217 </target>
218
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}" />
225 </target>
226
227 <target name="dist-lite" depends="clean,dist-lite-product,dist-lite-test">
228 </target>
229
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}" />
237         </copy>                         
238 </target>
239
240 <target name="dist"
241         depends="dist-lite,dist-javadoc"
242         description="copying compiled sources to dist location and copy documentation to forrest site">
243         <echo
244                 message="Copying build results for ${module.name} to a location where other modules can find it." />
245 </target>
246
247 <!-- ============================================================================
248         Check style, 
249         ============================================================================ -->
250
251 <target name="checkstyle" depends="testclasses">
252         <checkstyle config="${build.dir}/${checkstyle.rules}"
253                 failOnViolation="false">
254                 <classpath>
255                   <path refid="module.build.path"/>
256                 </classpath>
257                 <fileset dir="${module.source.dir}" includes="**/*.java" />
258                 <formatter type="plain" />
259         </checkstyle>
260         <checkstyle config="${build.dir}/${checkstyle.rules}"
261                 failOnViolation="false">
262                 <classpath>
263                   <pathelement path="${module.testbuild.path}"/>
264                 </classpath>
265                 <fileset dir="${module.test.dir}" includes="**/*.java" />
266                 <formatter type="plain" />
267         </checkstyle>
268 </target>
269
270 <!-- ============================================================================
271         Formatting source code.  
272         ============================================================================ -->
273 <target name="format" depends="init">
274         <jalopy loglevel="INFO" classpathref="module.testbuild.path"
275                 convention="${jalopy.rules}">
276                 <fileset dir="${module.source.dir}">
277                         <include name="**/*.java" />
278                 </fileset>
279                 <fileset dir="${module.test.dir}">
280                         <include name="**/*.java" />
281                 </fileset>
282         </jalopy>
283 </target>
284
285 <!-- =========================================================================
286         Check redundancy in the code
287         ========================================================================= -->
288 <target name="simian" depends="init">
289         <simian threshold="7">
290                 <fileset dir="${module.source.dir}" includes="**/*.java" />
291         </simian>
292 </target>
293
294
295 <!-- =========================================================================
296         Check dependencies using macker.
297         ========================================================================= -->
298 <property name="macker.file" value="macker.xml" />
299 <target name="macker" depends="compile">
300         <available file="${macker.file}" property="macker.file.found" />
301         <fail message="Macker source file ${macker.file} was not found."
302                 unless="macker.file.found" />
303         <macker>
304                 <rules dir="." includes="macker.xml" />
305                 <classes dir="${module.classes.dir}">
306                         <include name="**/*.class" />
307                 </classes>
308                 <classpath>
309                     <pathelement path="${module.classes.dir}" />
310                         <path refid="module.build.path" />
311                 </classpath>
312         </macker>
313 </target>
314
315
316 <!-- ===========================================================================
317         JUnit tests.
318         =========================================================================== -->
319
320 <target name="testclasses" depends="compile">
321         <mkdir dir="${module.test.dir}" />
322         <mkdir dir="${module.testresource.dir}" />
323         <mkdir dir="${module.testclasses.dir}" />
324                 <path id="test.classpath">
325                 <pathelement path="${module.classes.dir}" />
326                 <pathelement path="${module.test.dir}" />
327                 <path refid="module.testbuild.path" />
328                 <path refid="module.build.path" />
329         </path>
330         <javac srcdir="${module.test.dir}"
331                 destdir="${module.testclasses.dir}" 
332                 debug="${javac.debug}" debuglevel="${javac.debug.level}" compiler="modern"
333                 source="${javac.source}" failonerror="yes">
334                 <classpath>
335                     <path refid="test.classpath"/>
336                 </classpath>
337         </javac>
338         <copy todir="${module.testclasses.dir}">
339                 <fileset dir="${module.test.dir}" excludes="**/*.java" />
340                 <fileset dir="${module.testresource.dir}" />
341         </copy>
342 </target>
343
344 <!-- test-base is a target mean to be used by other targets. 
345         It expects one parameter names 'testedclasses' to indicate the directory
346         where the compiled test classes reside. 
347 -->
348
349 <target name="base-test-clean">
350   <delete file="coverage.ec"/>
351   <delete file="coverage.em"/>
352 </target>
353
354
355 <target name="base-test-impl" depends="testclasses">
356         <mkdir dir="${module.report.dir}" />
357         <antcall target="emma"/>
358         <junit haltonfailure="${junit.halt.on.failure}" printsummary="on" dir="." fork="yes" showoutput="yes">
359                 <batchtest todir="${module.report.dir}">
360                         <fileset dir="${module.testclasses.dir}">
361                                 <include name="${testclassnames}" />
362                                 <!--  exclude inner classes --> 
363                                 <exclude name="**/*$$*.class"/>
364                         </fileset>
365                 </batchtest>
366                 <formatter type="xml" />
367                 <classpath>
368                         <path refid="xmlschemas.path" />
369                         <pathelement path="${module.testclasses.dir}" />
370                         <pathelement path="${testedclasses}" />
371                         <pathelement path="${testlibrary}" />
372                         <pathelement path="${module.classes.dir}" />
373                         <pathelement path="${log4j.properties.dir}" /><!--  for log4j.properties -->
374                         <!-- the test resource directory is added to the path as well to make it
375                                 easy to access resources from tests -->
376                         <pathelement path="${module.testresource.dir}" />
377                         <path refid="module.testbuild.path" />
378                         <path refid="module.build.path" />
379                 </classpath>
380         </junit>
381 </target>
382
383 <target name="base-test-allclasses" unless="test">
384         <echo>Testing all classes</echo>
385         <antcall target="base-test-impl">
386                 <param name="testclassnames" value="**/*Test.class" />
387         </antcall>
388 </target>
389
390 <target name="base-test-singleclass" if="test">
391         <echo>Testing testcases that conform to the pattern *${test}*</echo>
392         <antcall target="base-test-impl">
393                 <param name="testclassnames" value="**/*${test}*.class" />
394         </antcall>
395 </target>
396
397 <target name="base-test">
398         <antcall target="base-test-allclasses" />
399         <antcall target="base-test-singleclass" />
400 </target>
401
402 <!-- Run junit test -->
403
404 <target name="test">
405         <antcall target="base-test">
406                 <param name="testedclasses" value="${module.classes.dir}" />
407         </antcall>
408 </target>
409
410 <!-- reporting target used by other targets. This should not depend on 
411         the test target to avoid unnecessary duplicate runs of the tests -->
412
413 <target name="base-reports" depends="init">
414         <mkdir dir="${module.report.dir}/html" />
415         <mkdir dir="${module.report.dir}/html/unit" />
416         <junitreport todir="${module.report.dir}" tofile="${unitreport}">
417                 <fileset dir="${module.report.dir}">
418                         <include name="TEST-*.xml" />
419                 </fileset>
420                 <report todir="${module.report.dir}/html/unit" />
421         </junitreport>
422 </target>
423
424 <!-- Run junit tests with HTML reporting -->
425
426 <target name="junit-reports" depends="test">
427         <antcall target="base-reports" />
428         <antcall target="emma-reports" />
429 </target>
430
431 <target name="reports">
432   <antcall target="junit-reports">
433     <param name="emma.enabled" value="true"/>
434   </antcall>
435 </target>
436
437  <!-- Instrument classes using emma --> 
438   
439   <target name="emma" depends="init_directory_properties">
440     <emma enabled="${emma.enabled}">
441       <instr instrpath="${module.classes.dir}" mode="overwrite"/>
442     </emma>
443   </target>
444   
445   <target name="emma-reports" depends="init_directory_properties" if="emma.enabled">
446     <mkdir dir="${module.emmareport.dir}"/>
447     <emma enabled="${emma.enabled}" >
448       <report sourcepath="${module.source.dir}">
449         <!-- collect all EMMA data dumps (metadata and runtime): -->
450         <infileset dir="." includes="*.em, *.ec" />
451
452         <txt outfile="${module.emmareport.dir}/report.txt"/>
453         <html outfile="${module.emmareport.dir}/index.html"/>
454         <!-- sourcepath>
455           <dirset dir="${src}" >
456             <include name="." /> 
457           </dirset>
458         </sourcepath -->
459       </report>
460     </emma>
461   </target>
462
463
464 <!--  ============================================================================
465       Database targets
466       ============================================================================ -->
467            
468 <!--  Runs a main program found in the test source tree. 
469       Properties:
470          - my.test.program: class name of the program to run 
471          - my.args: arguments to be passed to the program --> 
472 <target name="runTestProgram" depends="testclasses">
473         <java classname="${my.test.program}">
474             <arg line="${my.args}"/>
475                 <classpath>
476                         <path refid="xmlschemas.path" />
477                         <path refid="junit.path" />
478                         <pathelement path="${module.testclasses.dir}" />
479                         <pathelement path="${testedclasses}" />
480                         <pathelement path="${testlibrary}" />
481                         <pathelement path="${module.classes.dir}" />
482                         <pathelement path="${log4j.properties.dir}" /><!--  for log4j.properties -->
483                         <!-- the test resource directory is added to the path as well to make it
484                                 easy to access resources from tests -->
485                         <pathelement path="${module.testresource.dir}" />
486                         <path refid="module.testbuild.path" />
487                         <path refid="module.build.path" />
488                 </classpath>
489         </java>
490 </target>
491
492 <property name="database.starter" 
493           value="org.wamblee.persistence.test.DatabaseStarter"/>
494 <target name="startdb">
495     <echo>After the database has started, you must populate the database in some way.
496           For instance, using the schemaupdate ant target</echo>
497     <antcall target="runTestProgram">
498         <param name="my.test.program" value="${database.starter}"/>
499         <param name="my.args" value=""/>
500     </antcall>
501 </target>
502
503 <property name="schemaupdater" 
504           value="org.wamblee.test.HibernateUtils"/>
505 <target name="schemaupdate">
506     <antcall target="runTestProgram">
507         <param name="my.test.program" value="${schemaupdater}"/>
508         <param name="my.args" value="${hibernate.filelist}"/>
509     </antcall>
510 </target>
511
512 <target name="schemaexport" depends="init">
513     <mkdir dir="${module.sql.dir}" />
514     <echo>Generating schema in output file ${module.sql.dir}/hibernate.sql</echo>
515     <antcall target="runTestProgram">
516         <param name="my.test.program" value="${schemaupdater}"/>
517         <param name="my.args" value="-export ${module.sql.dir}/hibernate.sql ${hibernate.filelist}"/>
518     </antcall>
519 </target>
520
521 <!-- INCLUDED MARKER -->
522 <property name="build_trailer_included" value="true" />
523
524