(no commit message)
[utils] / build / header.xml
1 <!-- PROPERTIES -->
2
3 <target name="echoUserPropertiesFileFound" if="user.properties.found">
4   <echo>Using properties file ${user.property.file}</echo>
5 </target>
6     
7 <target name="echoUserPropertiesFileNotFound" unless="user.properties.found">
8   <echo>Properties file ${user.property.file} not found, reverting to defaults</echo>
9 </target>
10
11
12 <property name="project.home" value=".."/>
13 <property name="build.dir" value="${project.home}/build"/>
14 <property name="lib.dir" value="${project.home}/lib/wamblee"/>
15
16 <target name="download.dep">
17   <if>
18     <isset property="artifact"/>
19     <then>
20       <echo>Getting dependence ${group}/${artifact}/${version}</echo>
21       <dependencies verbose="true" fileSetId="my.deps"> 
22         <dependency group="${group}" artifact="${artifact}" version="${version}"/>
23       </dependencies> 
24       <copy todir="${download.dir}" flatten="yes">
25         <fileset refid="my.deps"/>
26       </copy>
27     </then>
28     <else>
29       <echo>Getting dependence ${group}/${version}</echo>
30       <dependencies verbose="true" fileSetId="my.deps"> 
31         <dependency group="${group}" version="${version}"/>
32       </dependencies> 
33       <copy todir="${download.dir}" flatten="yes">
34         <fileset refid="my.deps"/>
35       </copy>
36     </else>
37   </if>
38 </target>
39
40 <!-- LOG4j -->    
41 <target name="log4j.d">
42   <antcall target="download.dep">
43     <param name="group" value="log4j"/>
44     <param name="version" value="1.2.9"/>
45   </antcall>
46 </target>
47
48 <target name="commons-beanutils.d">
49   <antcall target="download.dep">
50     <param name="group" value="commons-beanutils"/>
51     <param name="version" value="1.7.0"/>
52   </antcall>
53 </target>
54
55 <target name="commons-collections.d">
56   <antcall target="download.dep">
57     <param name="group" value="commons-collections"/>
58     <param name="version" value="3.1"/>
59   </antcall>
60 </target>
61
62
63 <target name="commons-logging.d">
64   <antcall target="download.dep">
65     <param name="group" value="commons-logging"/>
66     <param name="artifact" value="commons-logging"/>
67     <param name="version" value="1.0.2"/>
68   </antcall>
69 </target>
70
71 <target name="commons-codec.d">
72   <antcall target="download.dep">
73     <param name="group" value="commons-codec"/>
74     <param name="version" value="1.3"/>
75   </antcall>
76 </target>
77
78
79 <target name="logging.d" depends="log4j.d,commons-logging.d">
80 </target>
81
82 <target name="dom4j.d">
83   <antcall target="download.dep">
84     <param name="group" value="dom4j"/>
85     <param name="version" value="1.6"/>
86   </antcall>
87   <antcall target="download.dep">
88     <param name="group" value="jaxen"/>
89     <param name="version" value="1.1-beta-4"/>
90   </antcall>
91 </target>
92
93 <target name="xerces.d">
94   <antcall target="download.dep">
95     <param name="group" value="ehcache"/>
96     <param name="version" value="1.1"/>
97   </antcall>
98 </target>
99
100 <target name="ehcache.d">
101   <antcall target="download.dep">
102     <param name="group" value="xerces"/>
103     <param name="version" value="2.4.0"/>
104   </antcall>
105 </target>
106
107 <target name="oro.d">
108   <antcall target="download.dep">
109     <param name="group" value="oro"/>
110     <param name="version" value="2.0.6"/>
111   </antcall>
112 </target>
113
114 <target name="cglib.d">
115   <antcall target="download.dep">
116     <param name="group" value="cglib"/>
117     <param name="version" value="2.1"/>
118   </antcall>
119 </target>
120
121 <target name="hibernate.d" depends="cglib.d,oro.d">
122   <antcall target="download.dep">
123     <param name="group" value="hibernate"/>
124     <param name="version" value="3.0.5"/>
125   </antcall>
126 </target>
127
128 <target name="hibernate.standalone.d" depends="hibernate.d">
129   <copy todir="${download.dir}">
130     <fileset dir="${special.lib.dir}/hibernate">
131        <include name="*.jar"/>
132     </fileset>
133   </copy>
134 </target>
135
136 <target name="spring.d">
137   <antcall target="download.dep">
138     <param name="group" value="springframework"/>
139     <param name="artifact" value="spring"/>
140     <param name="version" value="1.2.5"/>
141   </antcall>
142 </target>
143
144 <target name="httpclient.d">
145   <antcall target="download.dep">
146     <param name="group" value="commons-httpclient"/>
147     <param name="version" value="3.0"/>
148   </antcall>
149 </target>
150
151 <target name="jtidy.d">
152   <antcall target="download.dep">
153     <param name="group" value="jtidy"/>
154     <param name="version" value="4aug2000r7-dev"/>
155   </antcall>
156 </target>
157
158 <property name="support.dist.dir" value="${lib.dir}/support"/>
159 <target name="wamblee.support.d">
160   <copy todir="${download.dir}">
161     <fileset dir="${support.dist.dir}">
162       <include name="support.jar"/>
163     </fileset>
164   </copy>
165 </target>
166 <target name="wamblee.support.test.d">
167   <copy todir="${download.dir}">
168     <fileset dir="${support.dist.dir}">
169       <include name="support-test.jar"/>
170     </fileset>
171   </copy>
172 </target>
173
174 <property name="crawler.dist.dir" value="${lib.dir}/crawler"/>
175 <target name="wamblee.crawler.d">
176   <copy todir="${download.dir}">
177     <fileset dir="${crawler.dist.dir}">
178       <include name="crawler.jar"/>
179     </fileset>
180   </copy>
181 </target>
182 <target name="wamblee.crawler.test.d">
183   <copy todir="${download.dir}">
184     <fileset dir="${crawler.dist.dir}">
185       <include name="crawler-test.jar"/>
186     </fileset>
187   </copy>
188 </target>
189
190 <target name="junit.d">
191   <antcall target="download.dep">
192     <param name="group" value="junit"/>
193     <param name="version" value="3.8.1"/>
194   </antcall>
195   <copy todir="${download.dir}">
196     <fileset dir="${special.lib.dir}/test">
197        <include name="*.jar"/>
198     </fileset>
199   </copy>
200 </target>
201
202 <target name="emma.d">
203   <antcall target="download.dep">
204     <param name="group" value="emma"/>
205     <param name="artifact" value="emma"/>
206     <param name="version" value="2.0.5312"/>
207   </antcall>
208   <antcall target="download.dep">
209     <param name="group" value="emma"/>
210     <param name="artifact" value="emma_ant"/>
211     <param name="version" value="2.0.5312"/>
212   </antcall>
213 </target>
214
215 <target name="jmock.d">
216   <antcall target="download.dep">
217     <param name="group" value="jmock"/>
218     <param name="artifact" value="jmock"/>
219     <param name="version" value="1.0.1"/>
220   </antcall>
221   <antcall target="download.dep">
222     <param name="group" value="jmock"/>
223     <param name="artifact" value="jmock-cglib"/>
224     <param name="version" value="1.0.1"/>
225   </antcall>
226 </target>
227
228 <target name="dbunit.d">
229   <antcall target="download.dep">
230     <param name="group" value="dbunit"/>
231     <param name="version" value="2.1"/>
232   </antcall>
233 </target>
234
235
236 <target name="antlr.d">
237   <antcall target="download.dep">
238     <param name="group" value="antlr"/>
239     <param name="version" value="2.7.2"/>
240   </antcall>
241 </target>
242
243 <target name="checkstyle.d" depends="antlr.d,commons-beanutils.d,commons-logging.d,commons-collections.d">
244   <antcall target="download.dep">
245     <param name="group" value="checkstyle"/>
246     <param name="version" value="4.1"/>
247   </antcall>
248 </target>
249
250 <!-- common test dependencies for all test code --> 
251 <target name="test.d" depends="junit.d,jmock.d,dbunit.d,emma.d">
252 </target>
253
254 <!-- downloaded dependencies for ant tasks --> 
255 <target name="ant.d" depends="checkstyle.d">
256 </target>
257
258
259
260  <target name="import_header" unless="build_header_included">
261     
262     <!-- ========================================================================================
263          Locate user properties to (optionally) override defaults
264          ======================================================================================== -->
265  
266     <!--
267       Give user a chance to override without editing this file
268       (and without typing -D each time they run it).
269
270       The following properties must be defined in this file:
271       - jcoverage.home: root of the jcoverage installation. 
272       - jalopy.home: root of the jalopy installation. 
273     -->
274     <property name="user.property.file" value="${user.home}/wamblee.properties"/>
275     <available file="${user.property.file}" property="user.properties.found"/>
276     <property file="${user.property.file}"/>
277     
278     <antcall target="echoUserPropertiesFileFound"/>
279     <antcall target="echoUserPropertiesFileNotFound"/>
280
281     <!-- project properties defaults, can be overriden in the user's properties file -->
282     
283       <!--  The project.home property can also be overriden in a build.xml
284             in case the source is in a subdirectory and not necessarily
285             in the top-level directory --> 
286    
287     <property name="ant.lib.dir" value="${project.home}/lib/ant"/>
288     <property name="ant.downloaded.lib.dir" value="${project.home}/lib/ant/downloaded"/>
289     <property name="external.lib.dir" value="lib/external"/>
290     <property name="test.lib.dir" value="lib/test"/>
291     <property name="special.lib.dir" value="${project.home}/lib/special"/>
292     <property name="forrest.xdocs.dir" value="${project.home}/site/xdocs"/>
293     <property name="forrest.build.dir" value="${project.home}/site/build"/>
294     <property name="forrest.build.site.dir" value="${forrest.build.dir}/site"/>
295     <property name="build.properties.dir" value="${project.home}" />
296     <property name="build.properties.name" value="build.properties" />
297     
298     <mkdir dir="${external.lib.dir}"/>
299     <mkdir dir="${test.lib.dir}"/>
300     
301     <property name="conf.dir" value="conf"/>
302     <property name="log4j.properties.dir" value="${conf.dir}/properties"/>
303     
304     <!-- Compilation properties -->
305     <property name="javac.debug" value="true"/>
306     <property name="javac.debug.level" value="lines,vars,source"/>
307     <property name="javac.source" value="1.5"/>
308
309     <!-- ========================================================================================
310          Standard path definitions to be used with all projects 
311          ======================================================================================= -->
312     <property name="xmlschemas.dir" value="${conf.dir}/schemas"/>
313     <path id="xmlschemas.path">
314       <pathelement location="${xmlschemas.dir}"/>
315     </path>
316
317     <!-- ========================================================================================
318          Path definitions for external libraries.
319          ======================================================================================== -->
320  
321     <!-- Ignore system classpath! -->
322     <property name="build.sysclasspath" value="ignore" />
323
324     <!-- JUnit -->
325     <property name="junit.halt.on.failure" value="false"/>
326     <property name="unitreport" value="cl-unit.xml"/>
327     
328     <!-- DocCheck path -->
329     <property name="doccheck.home" value="${ant.lib.dir}/doccheck1.2b2/doccheck.jar"/>
330     <path id="doccheck.path">
331       <pathelement location="${doccheck.home}"/>
332     </path>
333     
334     <!-- PdfDoclet path -->
335     <property name="pdfdoclet.home" value="${ant.lib.dir}/pdfdoclet-1.0.2-all.jar"/>
336     <path id="pdfdoclet.path">
337       <pathelement location="${pdfdoclet.home}"/>
338     </path>
339         
340     <!-- Hibernate paths --> 
341     <!--  name of the file in the source directory containing
342           the names of hibernate files to look at in the correct order --> 
343     <property name="hibernate.home" value="${lib.dir}/hibernate-3.0"/>
344     <path id="hibernate.basic.path">
345       <fileset dir="${hibernate.home}">
346         <include name="*.jar"/>
347       </fileset>
348       <path refid="xerces.path"/>
349       <path refid="dom4j.path"/>
350     </path>
351     <path id="hibernate.appserver.path"> 
352       <path refid="hibernate.basic.path"/>
353       <fileset dir="${hibernate.home}/appserver">
354         <include name="*.jar"/>
355       </fileset>
356     </path>
357     <path id="hibernate.standalone.path"> 
358       <path refid="hibernate.basic.path"/>
359       <fileset dir="${hibernate.home}/standalone">
360         <include name="*.jar"/>
361       </fileset>
362     </path>
363
364     <!-- Commented the inclusion of a system-wide path in the user's environment into a 
365          classpath. System wide classpaths should not be used. -->
366     <!-- property name="classpath_id" value="build.path" / -->
367     <!-- property name="classpath" refid="${classpath_id}"/ -->
368     <property name="classpath" value=""/>
369     
370     
371     <!-- ========================================================================================
372          Database settings
373          ======================================================================================== -->
374     <property name="database" value="Derby"/>
375     
376     <!-- ========================================================================================
377          Ant task defs
378          ======================================================================================== -->
379  
380     <!-- ant-contrib integration --> 
381     <property name="ant.contrib.home" value="${ant.lib.dir}/ant-contrib-1.0b2"/>
382     <taskdef resource="net/sf/antcontrib/antlib.xml">
383       <classpath>
384         <pathelement location="${ant.contrib.home}/ant-contrib.jar" />
385       </classpath>
386     </taskdef>
387     
388     <!-- taskdef for ant-dependencies task --> 
389     <taskdef name="dependencies" classpath="${ant.lib.dir}/ant-dependencies.jar" 
390       classname="org.apache.tools.ant.taskdefs.optional.dependencies.Dependencies"/>
391   
392     <!-- Emma integration --> 
393     <path id="emma.lib">
394       <fileset dir="${test.lib.dir}" includes="emma*.jar"/>
395     </path>
396     <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
397     <property name="emma.enabled" value="false"/>
398     
399     <!-- checkstyle -->
400     <property name="checkstyle.home" value="${ant.downloaded.lib.dir}"/>
401     <taskdef resource="checkstyletask.properties">
402       <classpath>
403         <fileset dir="${checkstyle.home}">
404           <include name="*.jar"/>
405         </fileset>
406       </classpath>
407     </taskdef>
408     <property name="checkstyle.rules" value="style.xml"/>
409     <property name="checkstyle.test.rules" value="test-style.xml"/>
410     
411              
412     <!-- jalopy -->
413     <!-- TMP download this dependence as well 
414     <property name="jalopy.home" value="${lib.dir}/jalopy-ant-0.6.2"/>
415     <property name="jalopy.rules" value="${build.dir}/formatting-rules.xml"/>
416     <taskdef name="jalopy"
417          classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
418       <classpath>
419         <fileset dir="${jalopy.home}">
420           <include name="*.jar" />
421         </fileset>
422       </classpath>
423     </taskdef>
424     -->
425   
426     <!-- simian integration -->
427     <!-- TMP download this dependence as well 
428     <property name="simian.home" value="${lib.dir}/simian"/>
429     <taskdef resource="simiantask.properties" classpath="${simian.home}/simian.jar"/>
430     --> 
431     
432     <!-- macker integration -->
433     <!-- TMP download this dependence as well 
434     <property name="macker.home" value="${lib.dir}/macker-0.4.2"/>
435     <path id="macker.path">
436           <fileset dir="${macker.home}">
437             <include name="**/*.jar"/>
438           </fileset>
439     </path>
440     <taskdef name="macker"
441       classname="net.innig.macker.ant.MackerAntTask"
442       classpathref="macker.path"/>
443
444     --> 
445    
446     <!-- ========================================================================================
447          Information
448          ======================================================================================== -->
449     <echo level="debug" message="project.home=${project.home}"/>
450     <echo level="debug" message="project.libs=${project.libs}"/>
451     <echo level="debug" message="classpath=${classpath}"/>
452
453
454     <!-- ========================================================================================
455          Included marker
456          ======================================================================================== -->
457     <property name="build_header_included" value="true" />
458 </target>
459       
460 <!--  =================================================================
461      Sets up the directory definitions for the module
462      ================================================================= -->
463 <target name="init_directory_properties" depends="import_header">
464         <!-- Set module properties for this build -->
465
466         <property name="module.home" value="." />
467         
468         <!--  Replace the dash by a / to create a relative directory 
469               from a module name --> 
470         <propertyregex property="module.reldir" 
471                        input="${module.name}"
472                        regexp="-"
473                        replace="/"
474                        global="true"
475                        defaultValue="${module.name}"/>
476         <property name="module.build.dir"
477                 value="${build.dir}/${module.reldir}" />
478
479         <property name="module.api.forrest.dir" value="${forrest.build.site.dir}/api/${module.name}" />
480         <!-- property name="module.classes.dir"     value="${module.build.dir}/bin"/ -->
481         <!-- property name="module.testclasses.dir" value="${module.build.dir}/testbin"/ -->
482         <property name="module.classes.dir" value="bin" />
483         <property name="module.testclasses.dir" value="testbin" />
484         <!-- Directory where generated SQL will be put by the schema export-->
485         <property name="module.sql.dir" value="${module.build.dir}/sql" />
486
487
488         <property name="module.jcovclasses.dir"
489                 value="${module.build.dir}/testjcov" />
490         <property name="module.jars.dir" value="${module.build.dir}/jars" />
491         <property name="module.jar.file"
492                 value="${module.jars.dir}/${module.jar.name}" />
493         <property name="module.source.dir" value="${module.home}/src" />
494         <property name="module.forrest.src.dir" value="${module.home}/xdocs" />
495         <property name="module.ejbsource.dir" value="${module.home}/ejbsrc" />
496         <property name="module.test.dir" value="${module.home}/test" />
497         <property name="module.testjar.name"
498                 value="${module.name}-test.jar" />
499         <property name="module.testresourcesjar.name"
500                 value="${module.name}-test-resources.jar" />
501         <property name="module.resource.dir"
502                 value="${module.home}/resources" />
503         <property name="module.testresource.dir"
504                 value="${module.resource.dir}/test" />
505     <property name="module.testoutput.dir"
506         value="${module.resource.dir}/testoutput"/>
507         <property name="module.report.dir"
508                 value="${module.build.dir}/testresults" />
509         <property name="module.emmareport.dir"
510                 value="${module.report.dir}/html/emma"/>
511         <property name="module.docbase.dir"
512                 value="${module.build.dir}/javadoc" />
513         <property name="module.javadoc.dir"
514                 value="${module.docbase.dir}/api" />
515         <property name="module.javadocjar.name"
516                 value="${module.name}-doc.jar" />
517         <property name="module.testjavadocjar.name"
518                 value="${module.name}-test-doc.jar" />
519         <property name="module.testjavadoc.dir"
520                 value="${module.docbase.dir}/testapi" />
521         <property name="module.pdfdoc.dir"
522                 value="${module.docbase.dir}/pdf" />
523         <property name="module.doccheck.dir"
524                 value="${module.docbase.dir}/doccheck" />
525         <property name="module.jar.name" value="${module.name}.jar" />
526         
527         <!--  Replace the dash by a / to create a relative directory 
528               from a module name --> 
529         <property name="module.dist.dir" value="${lib.dir}/${module.reldir}" />
530 </target>
531
532 <!-- ============================================================================
533   Initialize the environment for other tasks. Normally, every task which
534   does not depend on any other task should at least depend on init. 
535   ============================================================================ -->
536   
537   <target name="help" depends="import_header">
538     <antcall target="help-within-module"/>
539     <antcall target="help-outside-module"/>
540   </target>
541   
542   <target name="help-within-module" depends="init_directory_properties" if="module.name">
543     <antcall target="help-impl"/>
544   </target>
545   
546   <target name="help-outside-module" unless="module.name">
547     <antcall target="help-outside-module-2">
548       <param name="module.name" value="MODULE_NAME"/>
549     </antcall>
550   </target>
551   
552   <target name="help-outside-module-2" depends="init_directory_properties">
553     <antcall target="help-impl"/>
554   </target>
555   
556   
557   <target name="help-impl">
558     <echo>
559     
560       Preparation:
561       
562       deps:          Download dependencies, this is necessary for using 
563                      any of the build targets.
564       clean-deps:    Remove downloaded dependencies. 
565       
566       General build targets: 
567       
568       clean:         Cleans up all build results (excluding the dist location).
569       compile:       Compiles all java clasess. Target dir ${module.classes.dir} 
570       jar:           Creates a jar file. Target: ${module.jar.file} 
571       dist:          Makes the build results available for other modules Target: ${module.dist.dir}. 
572       dist-lite:     Similar to dist but only creates the jars for code and test code. Useful
573                      during development because it takes much less time than the dist
574                      target
575       clean-dist:    Cleans up the dist directories. 
576       
577       Test: 
578       
579       test:          Compile and run tests. 
580       junit-reports: As test but generates a test report. Target: ${module.report.dir}(/html/unit) 
581       reports:       As junit-reports but also generates an emma test coverage
582                      report
583                      
584       Note: By specifying -Dtest=TestCaseName on the ant command line, 
585       only the specified testcase will be run. 
586       
587       Emma can also be executed manually:
588              
589          emma:          Overwrites the production classes by their instrumented versions.
590          emma-reports:  Generates emma code coverage reports after running the
591                         testcases with instrumented classes.
592       
593       Javadoc targets: 
594       
595       javadoc:       Generates javadoc. Target: ${module.javadoc.dir} 
596       doccheck:      Checks documentation. Target: ${module.doccheck.dir}
597       
598       Code analysis: 
599       
600       checkstyle:    Checks the style of the code. 
601       format:        Formats to the code in accordance with the checkstyle rules.
602       simian:        Analyse similarities in the code.
603       
604       Database targets: 
605       
606       For all targets below the database is configured using 
607       hibernate.properties (hibernate.dialect property) and 
608       the JDBC connection properties in database.properties. 
609       
610       The schemaexport and schemaupdate targets require the 
611       setting of a property named hibernate.filelist. The value
612       of the property must be the fully qualified class name of
613       a concrete subclass of ConfigFileList which has a default 
614       public constructor and defines the Hibernate mapping files that
615       can be used. 
616       
617       schemaexport:  Generate SQL code to create the required database structures.
618       
619       startdb:       Startup a lightweight database. The database
620       type to start is obtained from the currently
621       configured database. 
622       
623       schemaupdate:  Populate the database with a schema by running
624       Hibernate schemaupdate against the currently
625       configured database.  
626     </echo>
627   </target>
628   
629