(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"/>
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     <path id="emma.lib">
318       <fileset dir="${test.lib.dir}" includes="emma*.jar"/>
319     </path>
320     <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
321     <property name="emma.enabled" value="false"/>
322     
323     <!-- checkstyle -->
324     <property name="checkstyle.home" value="${ant.downloaded.lib.dir}"/>
325     <taskdef resource="checkstyletask.properties">
326       <classpath>
327         <fileset dir="${checkstyle.home}">
328           <include name="*.jar"/>
329         </fileset>
330       </classpath>
331     </taskdef>
332     <property name="checkstyle.rules" value="style.xml"/>
333     <property name="checkstyle.test.rules" value="test-style.xml"/>
334     
335              
336     <!-- jalopy -->
337     <!-- TMP download this dependence as well 
338     <property name="jalopy.home" value="${lib.dir}/jalopy-ant-0.6.2"/>
339     <property name="jalopy.rules" value="${build.dir}/formatting-rules.xml"/>
340     <taskdef name="jalopy"
341          classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
342       <classpath>
343         <fileset dir="${jalopy.home}">
344           <include name="*.jar" />
345         </fileset>
346       </classpath>
347     </taskdef>
348     -->
349   
350     <!-- simian integration -->
351     <!-- TMP download this dependence as well 
352     <property name="simian.home" value="${lib.dir}/simian"/>
353     <taskdef resource="simiantask.properties" classpath="${simian.home}/simian.jar"/>
354     --> 
355     
356     <!-- macker integration -->
357     <!-- TMP download this dependence as well 
358     <property name="macker.home" value="${lib.dir}/macker-0.4.2"/>
359     <path id="macker.path">
360           <fileset dir="${macker.home}">
361             <include name="**/*.jar"/>
362           </fileset>
363     </path>
364     <taskdef name="macker"
365       classname="net.innig.macker.ant.MackerAntTask"
366       classpathref="macker.path"/>
367
368     --> 
369     
370     <!-- ========================================================================================
371          Locate user properties to (optionally) override defaults
372          ======================================================================================== -->
373  
374     <!--
375       Give user a chance to override without editing this file
376       (and without typing -D each time they run it).
377
378       The following properties must be defined in this file:
379       - jcoverage.home: root of the jcoverage installation. 
380       - jalopy.home: root of the jalopy installation. 
381     -->
382     <property name="user.property.file" value="${user.home}/wamblee.properties"/>
383     <available file="${user.property.file}" property="user.properties.found"/>
384     <property file="${user.property.file}"/>
385     
386     <antcall target="echoUserPropertiesFileFound"/>
387     <antcall target="echoUserPropertiesFileNotFound"/>
388
389     <!-- project properties defaults, can be overriden in the user's properties file -->
390     
391       <!--  The project.home property can also be overriden in a build.xml
392             in case the source is in a subdirectory and not necessarily
393             in the top-level directory --> 
394    
395   
396         <if>
397           <isset property="webroot.dir"/>
398           <then>
399             <property name="external.lib.dir" value="${webroot.dir}/WEB-INF/lib"/>
400           </then>
401           <else>
402             <property name="external.lib.dir" value="lib/external"/>
403           </else>
404         </if>
405    
406     <property name="build.properties.dir" value="${project.home}" />
407     <property name="build.properties.name" value="build.properties" />
408     
409     <mkdir dir="${external.lib.dir}"/>
410     <mkdir dir="${test.lib.dir}"/>
411     
412     <property name="conf.dir" value="conf"/>
413     <property name="log4j.properties.dir" value="${conf.dir}/properties"/>
414     
415     <!-- Compilation properties -->
416     <property name="javac.debug" value="true"/>
417     <property name="javac.debug.level" value="lines,vars,source"/>
418     <property name="javac.source" value="1.5"/>
419
420     <!-- ========================================================================================
421          Standard path definitions to be used with all projects 
422          ======================================================================================= -->
423     <property name="xmlschemas.dir" value="${conf.dir}/schemas"/>
424     <path id="xmlschemas.path">
425       <pathelement location="${xmlschemas.dir}"/>
426     </path>
427
428     <!-- ========================================================================================
429          Path definitions for external libraries.
430          ======================================================================================== -->
431  
432     <!-- Ignore system classpath! -->
433     <property name="build.sysclasspath" value="ignore" />
434
435     <!-- JUnit -->
436     <property name="junit.halt.on.failure" value="false"/>
437     <property name="unitreport" value="cl-unit.xml"/>
438     
439     <!-- DocCheck path -->
440     <property name="doccheck.home" value="${ant.lib.dir}/doccheck1.2b2/doccheck.jar"/>
441     <path id="doccheck.path">
442       <pathelement location="${doccheck.home}"/>
443     </path>
444     
445     <!-- PdfDoclet path -->
446     <property name="pdfdoclet.home" value="${ant.lib.dir}/pdfdoclet-1.0.2-all.jar"/>
447     <path id="pdfdoclet.path">
448       <pathelement location="${pdfdoclet.home}"/>
449     </path>
450         
451     <!-- Hibernate paths --> 
452     <!--  name of the file in the source directory containing
453           the names of hibernate files to look at in the correct order --> 
454     <property name="hibernate.home" value="${lib.dir}/hibernate-3.0"/>
455     <path id="hibernate.basic.path">
456       <fileset dir="${hibernate.home}">
457         <include name="*.jar"/>
458       </fileset>
459       <path refid="xerces.path"/>
460       <path refid="dom4j.path"/>
461     </path>
462     <path id="hibernate.appserver.path"> 
463       <path refid="hibernate.basic.path"/>
464       <fileset dir="${hibernate.home}/appserver">
465         <include name="*.jar"/>
466       </fileset>
467     </path>
468     <path id="hibernate.standalone.path"> 
469       <path refid="hibernate.basic.path"/>
470       <fileset dir="${hibernate.home}/standalone">
471         <include name="*.jar"/>
472       </fileset>
473     </path>
474
475     <!-- Commented the inclusion of a system-wide path in the user's environment into a 
476          classpath. System wide classpaths should not be used. -->
477     <!-- property name="classpath_id" value="build.path" / -->
478     <!-- property name="classpath" refid="${classpath_id}"/ -->
479     <property name="classpath" value=""/>
480     
481     
482     <!-- ========================================================================================
483          Database settings
484          ======================================================================================== -->
485     <property name="database" value="Derby"/>
486     
487   
488    
489     <!-- ========================================================================================
490          Information
491          ======================================================================================== -->
492     <echo level="debug" message="project.home=${project.home}"/>
493     <echo level="debug" message="project.libs=${project.libs}"/>
494     <echo level="debug" message="classpath=${classpath}"/>
495
496
497     <!-- ========================================================================================
498          Included marker
499          ======================================================================================== -->
500     <property name="build_header_included" value="true" />
501 </target>
502       
503 <!--  =================================================================
504      Sets up the directory definitions for the module
505      ================================================================= -->
506 <target name="init_directory_properties" depends="import_header">
507         <!-- Set module properties for this build -->
508
509         <property name="module.home" value="." />
510         
511         <!--  Replace the dash by a / to create a relative directory 
512               from a module name --> 
513         <propertyregex property="module.reldir" 
514                        input="${module.name}"
515                        regexp="-"
516                        replace="/"
517                        global="true"
518                        defaultValue="${module.name}"/>
519         <!-- property name="module.build.dir"
520                 value="${build.dir}/${module.reldir}" / -->
521     <property name="module.build.dir" value="build"/>
522         <property name="module.api.forrest.dir" value="${forrest.build.site.dir}/api/${module.name}" />
523         <if>
524           <isset property="webroot.dir"/>
525           <then>
526             <property name="module.classes.dir" value="${webroot.dir}/WEB-INF/classes" />
527           </then>
528           <else>
529             <property name="module.classes.dir" value="${module.build.dir}/bin" />
530           </else>
531         </if>
532         
533         <property name="module.testclasses.dir" value="${module.build.dir}/testbin" />
534         <!-- Directory where generated SQL will be put by the schema export-->
535         <property name="module.sql.dir" value="${module.build.dir}/sql" />
536
537
538         <property name="module.jcovclasses.dir"
539                 value="${module.build.dir}/testjcov" />
540         <property name="module.jars.dir" value="${module.build.dir}/jars" />
541         <property name="module.jar.file"
542                 value="${module.jars.dir}/${module.jar.name}" />
543         <property name="module.source.dir" value="${module.home}/src" />
544         <property name="module.forrest.src.dir" value="${module.home}/xdocs" />
545         <property name="module.ejbsource.dir" value="${module.home}/ejbsrc" />
546         <property name="module.test.dir" value="${module.home}/test" />
547         <property name="module.testjar.name"
548                 value="${module.name}-test.jar" />
549         <property name="module.testresourcesjar.name"
550                 value="${module.name}-test-resources.jar" />
551         <property name="module.resource.dir"
552                 value="${module.home}/resources" />
553         <property name="module.testresource.dir"
554                 value="${module.resource.dir}/test" />
555     <property name="module.testoutput.dir"
556         value="${module.resource.dir}/testoutput"/>
557         <property name="module.report.dir"
558                 value="${module.build.dir}/testresults" />
559         <property name="module.emmareport.dir"
560                 value="${module.report.dir}/html/emma"/>
561         <property name="module.docbase.dir"
562                 value="${module.build.dir}/docs" />
563         <property name="module.javadoc.dir"
564                 value="${module.docbase.dir}/api" />
565         <property name="module.javadocjar.name"
566                 value="${module.name}-doc.jar" />
567         <property name="module.testjavadocjar.name"
568                 value="${module.name}-test-doc.jar" />
569         <property name="module.testjavadoc.dir"
570                 value="${module.docbase.dir}/testapi" />
571         <property name="module.pdfdoc.dir"
572                 value="${module.docbase.dir}/pdf" />
573         <property name="module.doccheck.dir"
574                 value="${module.docbase.dir}/doccheck" />
575         <property name="module.checkstyle.dir"
576             value="${module.docbase.dir}/checkstyle" />
577         <property name="module.jar.name" value="${module.name}.jar" />
578         
579         <!--  Replace the dash by a / to create a relative directory 
580               from a module name --> 
581         <property name="module.dist.dir" value="${lib.dir}/${module.reldir}" />
582 </target>
583
584 <!-- ============================================================================
585   Initialize the environment for other tasks. Normally, every task which
586   does not depend on any other task should at least depend on init. 
587   ============================================================================ -->
588   
589   <target name="help" depends="import_header">
590     <antcall target="help-within-module"/>
591     <antcall target="help-outside-module"/>
592   </target>
593   
594   <target name="help-within-module" depends="init_directory_properties" if="module.name">
595     <antcall target="help-impl"/>
596   </target>
597   
598   <target name="help-outside-module" unless="module.name">
599     <antcall target="help-outside-module-2">
600       <param name="module.name" value="MODULE_NAME"/>
601     </antcall>
602   </target>
603   
604   <target name="help-outside-module-2" depends="init_directory_properties">
605     <antcall target="help-impl"/>
606   </target>
607   
608   
609   <target name="help-impl">
610     <echo>
611     
612       Preparation:
613       
614       To execute with a specific proxy host and port, start ant with the 
615       command-line options   -Dproxyhost=hostname -Dproxyport=portnumber.
616       
617       deps:          Download dependencies, this is necessary for using 
618                      any of the build targets.
619       clean-deps:    Remove downloaded dependencies. 
620       
621       General build targets: 
622       
623       clean:         Cleans up all build results (excluding the dist location).
624       compile:       Compiles all java clasess. Target dir ${module.classes.dir} 
625       jar:           Creates a jar file. Target: ${module.jar.file} 
626       dist:          Makes the build results available for other modules Target: ${module.dist.dir}. 
627       dist-lite:     Similar to dist but only creates the jars for code and test code. Useful
628                      during development because it takes much less time than the dist
629                      target
630       clean-dist:    Cleans up the dist directories. 
631       
632       Test: 
633       
634       test:          Compile and run tests. 
635       junit-reports: As test but generates a test report. Target: ${module.report.dir}(/html/unit) 
636       reports:       As junit-reports but also generates an emma test coverage
637                      report
638                      
639       Note: By specifying -Dtest=TestCaseName on the ant command line, 
640       only the specified testcase will be run. 
641       
642       Emma can also be executed manually:
643              
644          emma:          Overwrites the production classes by their instrumented versions.
645          emma-reports:  Generates emma code coverage reports after running the
646                         testcases with instrumented classes.
647       
648       Javadoc targets: 
649       
650       javadoc:       Generates javadoc. Target: ${module.javadoc.dir} 
651       doccheck:      Checks documentation. Target: ${module.doccheck.dir}
652           
653           Forrest:
654           
655           forrest:       Generates project docs using forrest. 
656       
657       Code analysis: 
658       
659       checkstyle:    Checks the style of the code. 
660       format:        Formats to the code in accordance with the checkstyle rules.
661       simian:        Analyse similarities in the code.
662           
663           Building a web application: 
664           
665           To build a web application archive (WAR) you must set the property
666           webroot.dir to the value of the directory which is the root of your
667           web application. This must be done before the header.xl is 
668           sourced. The build support will then make sure that 
669           classes and libs are put in the correct directories below 
670           ${webroot.dir}/WEB-INF, and it will build a web archive. 
671       
672       Database targets:  ** database targets are not functional yet **
673       
674       For all targets below the database is configured using 
675       hibernate.properties (hibernate.dialect property) and 
676       the JDBC connection properties in database.properties. 
677       
678       The schemaexport and schemaupdate targets require the 
679       setting of a property named hibernate.filelist. The value
680       of the property must be the fully qualified class name of
681       a concrete subclass of ConfigFileList which has a default 
682       public constructor and defines the Hibernate mapping files that
683       can be used. 
684       
685       schemaexport:  Generate SQL code to create the required database structures.
686       
687       startdb:       Startup a lightweight database. The database
688       type to start is obtained from the currently
689       configured database. 
690       
691       schemaupdate:  Populate the database with a schema by running
692       Hibernate schemaupdate against the currently
693       configured database.  
694     </echo>
695   </target>
696   
697