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