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