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