(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-impl">
252    <checkstyle config="${build.dir}/${checkstyle.rules}"
253                 failOnViolation="false">
254                 <classpath>
255                   <pathelement path="${checkstyle.classpath}"/>
256                 </classpath>
257                 <fileset dir="${checkstyle.srcdir}" includes="**/*.java"/>
258                 <formatter type="xml" tofile="${module.checkstyle.dir}/${checkstyle.report}.xml"/>
259         </checkstyle>
260         <style style="${build.dir}/checkstyle-simple.xsl"
261                    in="${module.checkstyle.dir}/${checkstyle.report}.xml"
262                    out="${module.checkstyle.dir}/${checkstyle.report}.html"/>
263         <echo>Results are available at ${module.checkstyle.dir}/${checkstyle.report}.html</echo>
264 </target>
265
266 <target name="checkstyle" depends="testclasses">
267     <mkdir dir="${module.checkstyle.dir}"/>
268         <antcall target="checkstyle-impl">
269           <param name="checkstyle.classpath" refid="module.build.path"/>
270           <param name="checkstyle.srcdir" value="${module.source.dir}"/>
271           <param name="checkstyle.report" value="source-results"/>
272         </antcall>
273         <antcall target="checkstyle-impl">
274           <param name="checkstyle.classpath" refid="module.testbuild.path"/>
275           <param name="checkstyle.srcdir" value="${module.test.dir}"/>
276           <param name="checkstyle.report" value="test-results"/>
277         </antcall>
278 </target>
279
280 <!-- ============================================================================
281         Formatting source code.  
282         ============================================================================ -->
283 <target name="format" depends="init">
284         <jalopy loglevel="INFO" classpathref="module.testbuild.path"
285                 convention="${jalopy.rules}">
286                 <fileset dir="${module.source.dir}">
287                         <include name="**/*.java" />
288                 </fileset>
289                 <fileset dir="${module.test.dir}">
290                         <include name="**/*.java" />
291                 </fileset>
292         </jalopy>
293 </target>
294
295 <!-- =========================================================================
296         Check redundancy in the code
297         ========================================================================= -->
298 <target name="simian" depends="init">
299         <simian threshold="7">
300                 <fileset dir="${module.source.dir}" includes="**/*.java" />
301         </simian>
302 </target>
303
304
305 <!-- =========================================================================
306         Check dependencies using macker.
307         ========================================================================= -->
308 <property name="macker.file" value="macker.xml" />
309 <target name="macker" depends="compile">
310         <available file="${macker.file}" property="macker.file.found" />
311         <fail message="Macker source file ${macker.file} was not found."
312                 unless="macker.file.found" />
313         <macker>
314                 <rules dir="." includes="macker.xml" />
315                 <classes dir="${module.classes.dir}">
316                         <include name="**/*.class" />
317                 </classes>
318                 <classpath>
319                     <pathelement path="${module.classes.dir}" />
320                         <path refid="module.build.path" />
321                 </classpath>
322         </macker>
323 </target>
324
325
326 <!-- ===========================================================================
327         JUnit tests.
328         =========================================================================== -->
329
330 <target name="testclasses" depends="compile">
331         <mkdir dir="${module.test.dir}" />
332         <mkdir dir="${module.testresource.dir}" />
333         <mkdir dir="${module.testclasses.dir}" />
334                 <path id="test.classpath">
335                 <pathelement path="${module.classes.dir}" />
336                 <pathelement path="${module.test.dir}" />
337                 <path refid="module.testbuild.path" />
338                 <path refid="module.build.path" />
339         </path>
340         <javac srcdir="${module.test.dir}"
341                 destdir="${module.testclasses.dir}" 
342                 debug="${javac.debug}" debuglevel="${javac.debug.level}" compiler="modern"
343                 source="${javac.source}" failonerror="yes">
344                 <classpath>
345                     <path refid="test.classpath"/>
346                 </classpath>
347         </javac>
348         <copy todir="${module.testclasses.dir}">
349                 <fileset dir="${module.test.dir}" excludes="**/*.java" />
350                 <fileset dir="${module.testresource.dir}" />
351         </copy>
352 </target>
353
354 <!-- test-base is a target mean to be used by other targets. 
355         It expects one parameter names 'testedclasses' to indicate the directory
356         where the compiled test classes reside. 
357 -->
358
359 <target name="base-test-clean">
360   <delete file="coverage.ec"/>
361   <delete file="coverage.em"/>
362 </target>
363
364
365 <target name="base-test-impl" depends="testclasses">
366         <mkdir dir="${module.report.dir}" />
367         <antcall target="emma"/>
368         <junit haltonfailure="${junit.halt.on.failure}" printsummary="on" dir="." fork="yes" showoutput="yes">
369                 <batchtest todir="${module.report.dir}">
370                         <fileset dir="${module.testclasses.dir}">
371                                 <include name="${testclassnames}" />
372                                 <!--  exclude inner classes --> 
373                                 <exclude name="**/*$$*.class"/>
374                         </fileset>
375                 </batchtest>
376                 <formatter type="xml" />
377                 <classpath>
378                         <path refid="xmlschemas.path" />
379                         <pathelement path="${module.testclasses.dir}" />
380                         <pathelement path="${testedclasses}" />
381                         <pathelement path="${testlibrary}" />
382                         <pathelement path="${module.classes.dir}" />
383                         <pathelement path="${log4j.properties.dir}" /><!--  for log4j.properties -->
384                         <!-- the test resource directory is added to the path as well to make it
385                                 easy to access resources from tests -->
386                         <pathelement path="${module.testresource.dir}" />
387                         <path refid="module.testbuild.path" />
388                         <path refid="module.build.path" />
389                 </classpath>
390         </junit>
391 </target>
392
393 <target name="base-test-allclasses" unless="test">
394         <echo>Testing all classes</echo>
395         <antcall target="base-test-impl">
396                 <param name="testclassnames" value="**/*Test.class" />
397         </antcall>
398 </target>
399
400 <target name="base-test-singleclass" if="test">
401         <echo>Testing testcases that conform to the pattern *${test}*</echo>
402         <antcall target="base-test-impl">
403                 <param name="testclassnames" value="**/*${test}*.class" />
404         </antcall>
405 </target>
406
407 <target name="base-test">
408         <antcall target="base-test-allclasses" />
409         <antcall target="base-test-singleclass" />
410 </target>
411
412 <!-- Run junit test -->
413
414 <target name="test">
415         <antcall target="base-test">
416                 <param name="testedclasses" value="${module.classes.dir}" />
417         </antcall>
418 </target>
419
420 <!-- reporting target used by other targets. This should not depend on 
421         the test target to avoid unnecessary duplicate runs of the tests -->
422
423 <target name="base-reports" depends="init">
424         <mkdir dir="${module.report.dir}/html" />
425         <mkdir dir="${module.report.dir}/html/unit" />
426         <junitreport todir="${module.report.dir}" tofile="${unitreport}">
427                 <fileset dir="${module.report.dir}">
428                         <include name="TEST-*.xml" />
429                 </fileset>
430                 <report todir="${module.report.dir}/html/unit" />
431         </junitreport>
432 </target>
433
434 <!-- Run junit tests with HTML reporting -->
435
436 <target name="junit-reports" depends="test">
437         <antcall target="base-reports" />
438         <antcall target="emma-reports" />
439 </target>
440
441 <target name="reports">
442   <antcall target="junit-reports">
443     <param name="emma.enabled" value="true"/>
444   </antcall>
445 </target>
446
447  <!-- Instrument classes using emma --> 
448   
449   <target name="emma" depends="init_directory_properties">
450     <emma enabled="${emma.enabled}">
451       <instr instrpath="${module.classes.dir}" mode="overwrite"/>
452     </emma>
453   </target>
454   
455   <target name="emma-reports" depends="init_directory_properties" if="emma.enabled">
456     <mkdir dir="${module.emmareport.dir}"/>
457     <emma enabled="${emma.enabled}" >
458       <report sourcepath="${module.source.dir}">
459         <!-- collect all EMMA data dumps (metadata and runtime): -->
460         <infileset dir="." includes="*.em, *.ec" />
461
462         <txt outfile="${module.emmareport.dir}/report.txt"/>
463         <html outfile="${module.emmareport.dir}/index.html"/>
464         <!-- sourcepath>
465           <dirset dir="${src}" >
466             <include name="." /> 
467           </dirset>
468         </sourcepath -->
469       </report>
470     </emma>
471   </target>
472
473
474 <!--  ============================================================================
475       Database targets
476       ============================================================================ -->
477            
478 <!--  Runs a main program found in the test source tree. 
479       Properties:
480          - my.test.program: class name of the program to run 
481          - my.args: arguments to be passed to the program --> 
482 <target name="runTestProgram" depends="testclasses">
483         <java classname="${my.test.program}">
484             <arg line="${my.args}"/>
485                 <classpath>
486                         <path refid="xmlschemas.path" />
487                         <path refid="junit.path" />
488                         <pathelement path="${module.testclasses.dir}" />
489                         <pathelement path="${testedclasses}" />
490                         <pathelement path="${testlibrary}" />
491                         <pathelement path="${module.classes.dir}" />
492                         <pathelement path="${log4j.properties.dir}" /><!--  for log4j.properties -->
493                         <!-- the test resource directory is added to the path as well to make it
494                                 easy to access resources from tests -->
495                         <pathelement path="${module.testresource.dir}" />
496                         <path refid="module.testbuild.path" />
497                         <path refid="module.build.path" />
498                 </classpath>
499         </java>
500 </target>
501
502 <property name="database.starter" 
503           value="org.wamblee.persistence.test.DatabaseStarter"/>
504 <target name="startdb">
505     <echo>After the database has started, you must populate the database in some way.
506           For instance, using the schemaupdate ant target</echo>
507     <antcall target="runTestProgram">
508         <param name="my.test.program" value="${database.starter}"/>
509         <param name="my.args" value=""/>
510     </antcall>
511 </target>
512
513 <property name="schemaupdater" 
514           value="org.wamblee.test.HibernateUtils"/>
515 <target name="schemaupdate">
516     <antcall target="runTestProgram">
517         <param name="my.test.program" value="${schemaupdater}"/>
518         <param name="my.args" value="${hibernate.filelist}"/>
519     </antcall>
520 </target>
521
522 <target name="schemaexport" depends="init">
523     <mkdir dir="${module.sql.dir}" />
524     <echo>Generating schema in output file ${module.sql.dir}/hibernate.sql</echo>
525     <antcall target="runTestProgram">
526         <param name="my.test.program" value="${schemaupdater}"/>
527         <param name="my.args" value="-export ${module.sql.dir}/hibernate.sql ${hibernate.filelist}"/>
528     </antcall>
529 </target>
530
531 <!-- INCLUDED MARKER -->
532 <property name="build_trailer_included" value="true" />
533
534