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