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