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