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