root/trunk/build/buildTools/deftasks.xml

Revision 3180 (checked in by douglm, 2 years ago)

Fixed a build bug that caused a build failure after a clean.
Removed a lot of copying of files. There's now a definition of exactly which libraries are needed for the ears. This allows us to be more specific about which jars get loaded

Removed some geronimo stuff added a while back. It was all out of date.

Line 
1 <!-- Define a number of tasks and macros
2      deftasks:  define someuseful build tasks
3      projectDefs: standard project definitions
4      xMsg: x=info,debug etc. For message output
5
6      Authors: Mike Douglass   douglm rpi.edu
7 -->
8
9 <project name="do.deftasks" basedir="." default="">
10   <macrodef name="deftasks">
11     <sequential>
12       <path id="build.cp">
13         <fileset dir="${build.dir}">
14           <include name="*.jar"/>
15         </fileset>
16       </path>
17  
18       <taskdef name="forEachApp"
19                classname="org.bedework.deployment.ForEachAppTask">
20         <classpath refid="build.cp"/>
21       </taskdef>
22      
23       <taskdef name="forApp"
24                classname="org.bedework.deployment.ForAppTask">
25         <classpath refid="build.cp"/>
26       </taskdef>
27
28       <taskdef name="resolveFile"
29                classname="org.bedework.deployment.ResolveFile">
30         <classpath refid="build.cp"/>
31       </taskdef>
32
33       <taskdef name="makeLangXsl"
34                classname="org.bedework.deployment.MakeLangXsl">
35         <classpath refid="build.cp"/>
36       </taskdef>
37
38       <taskdef name="applicationXml"
39                classname="org.bedework.deployment.ApplicationXmlTask">
40         <classpath refid="build.cp"/>
41       </taskdef>
42     </sequential>
43   </macrodef>
44  
45   <macrodef name="projectDefs">
46     <attribute name="name"/>
47     <attribute name="version"/>
48     <attribute name="deployment-name" default=""/>
49     <attribute name="subproject" default="false"/>
50     <sequential>
51       <property name="project.name" value="@{name}"/>
52      
53       <property name="project.version" value="@{version}"/>
54      
55       <property name="dist.home" location="${project.home}/dist"/>
56       <mkdir dir="${dist.home}" />
57
58       <property name="lib.dir" location="${project.home}/lib"/>
59
60       <property name="build.dir" location="${bedework.home}/build"/>
61
62       <property name="buildjar" location="${build.dir}/buildTools/buildjar.xml"/>
63       <property name="buildwar" location="${build.dir}/buildwar.xml"/>
64       <property name="buildsh" location="${build.dir}/buildsh.xml"/>
65
66       <property name="resources.dir" location="${project.home}/resources"/>
67
68       <property name="org.bedework.libcache.dir"
69                 location="${bedework.home}/libcache"/>
70      
71       <property name="org.bedework.temp.dir"
72                 location="${dist.home}/temp" />
73
74       <if>
75         <istrue value="@{subproject}" />
76         <then>
77           <property name="source.home" location="${project.home}/src"/>
78         </then>
79         <else>
80           <delete dir="${org.bedework.temp.dir}" />
81           <mkdir dir="${org.bedework.temp.dir}" />
82          
83           <property name="org.bedework.deployment.name"
84                     value="@{deployment-name}" />
85
86           <deftasks/>
87         </else>
88       </if>
89
90       <import file="${build.dir}/buildTools/getJar.xml"/>
91     </sequential>
92   </macrodef>
93
94   <!-- =====================================================================
95        Assumes projectDefs was called previously.
96        ===================================================================== -->
97   <macrodef name="projectInit">
98     <sequential>
99       <infoMsg message="* =========== Building ${project.name}" />
100      
101       <delete dir="${lib.dir}" />
102       <mkdir dir="${lib.dir}" />
103
104       <property name="test.data.dir"
105                 location="${dist.home}/test-data" />
106
107       <property name="test.reports.dir"
108                 location="${dist.home}/test-reports" />
109
110       <property name="org.bedework.empty.dir"
111                 location="${dist.home}/empty-dir" />
112       <mkdir dir="${org.bedework.empty.dir}" />
113
114       <fileset id="empty.fileset" dir="${org.bedework.empty.dir}"
115                excludes="*" />
116
117       <!-- ==================== Compilation Classpath ==================== -->
118
119       <path id="compile.classpath">
120         <fileset dir="${lib.dir}">
121            <include name="*.jar"/>
122         </fileset>
123         <fileset dir="${dist.home}">
124            <include name="*.jar"/>
125         </fileset>
126       </path>
127     </sequential>
128   </macrodef>
129
130   <!-- =====================================================================
131        Assumes projectDefs was called previously.
132        Set things up ready for deployment
133        ===================================================================== -->
134   <macrodef name="deployInit">
135     <attribute name="ear-name"/>
136     <sequential>
137       <!-- Where we put ear stuff -->
138       <if>
139         <isset property="org.bedework.global.build.ear" />
140         <then>
141           <property name="app.ear.file.name"
142                     value="@{ear-name}.ear" />
143
144           <property name="org.bedework.ear.name"
145                     value="@{ear-name}" />
146
147           <property name="org.bedework.ear.templib"
148                     location="${org.bedework.temp.dir}/earlib" />
149
150           <property name="org.bedework.ear.properties.dir"
151                     location="${org.bedework.temp.dir}/ear-properties" />
152
153           <delete dir="${org.bedework.ear.templib}" />
154           <mkdir dir="${org.bedework.ear.templib}" />
155
156           <delete dir="${org.bedework.ear.properties.dir}" />
157           <mkdir dir="${org.bedework.ear.properties.dir}" />
158         </then>
159       </if>
160      
161       <property name="org.bedework.temp.shellscr.home"
162                 location="${org.bedework.temp.dir}/shellscr" />
163
164       <property name="org.bedework.temp.extrajars.dir"
165                 location="${org.bedework.temp.dir}/extrajars" />
166
167       <!-- Preserve extra jars for ear builds -->
168       <property name="org.bedework.temp.ear.extrajars.dir"
169                 location="${org.bedework.temp.dir}/earextrajars" />
170      
171       <property name="org.bedework.global.context.roots"
172                 location="${org.bedework.temp.dir}/context-roots.properties" />
173
174       <!-- ===== End of stuff in main bedework deployment build file ======   -->
175      
176       <!-- Clean up before we start -->
177       <delete dir="${org.bedework.temp.wars.home}" />
178       <mkdir dir="${org.bedework.temp.wars.home}" />
179
180       <delete dir="${org.bedework.temp.ear.extrajars.dir}" />
181       <mkdir dir="${org.bedework.temp.ear.extrajars.dir}" />
182
183       <delete dir="${org.bedework.temp.extrajars.dir}" />
184       <mkdir dir="${org.bedework.temp.extrajars.dir}" />
185     </sequential>
186   </macrodef>
187  
188   <macrodef name="deployTerm">
189     <sequential>
190       <ant antfile="${build.dir}/../deployment/termination/webapp/build.xml"
191            target="deploy" inheritRefs="true" />
192      
193       <!-- Platform specific -->
194       <ant antfile="${build.dir}/../deployment/termination/build.xml"
195            target="deploy" inheritRefs="true" />
196     </sequential>
197   </macrodef>
198  
199   <!-- Standard targets for build files. Two targets need to be overridden by
200        the importing task
201        
202        init - carry out project specific initialisation
203        build-source - builds the source to creat ejars.
204     -->
205  
206   <!-- Override this -->
207   <target name="init" />
208
209   <!-- Override this -->
210   <target name="build-source" />
211
212   <!-- =================================================================
213        Clean out all library files from other projects and all generated
214        files in preparation for a complete rebuild.
215
216        Needed because switching versions leaves a load of old bedework
217        generated stuff in the libraries.
218        ================================================================= -->
219   <target name="deep-clean" depends="clean">
220     <delete dir="${lib.dir}" />
221   </target>
222
223   <!-- =================================================================
224        Clean all generated files
225        ================================================================= -->
226   <target name="clean">
227     <delete dir="${dist.home}" />
228   </target>
229
230   <!-- =================================================================
231        Clean up after a build.
232        ================================================================= -->
233   <target name="cleanup">
234     <!--
235     <delete dir="${org.bedework.empty.dir}" />
236     -->
237   </target>
238
239   <!-- ========================== Base build Targets ===================
240        Here we have one target building the classes and interfaces that make
241        up the access control suite.
242        ================================================================= -->
243
244   <target name="clean-build" depends="clean,build"
245           description="Clean and compile access control classes"/>
246
247   <target name="clean-build-all" depends="clean,build-all"
248           description="Clean and compile access control classes"/>
249
250   <target name="build" depends="init,build-source,cleanup"
251           description="Compile access control classes"/>
252
253   <target name="build-all" depends="build"
254           description="Compile access control classes"/>
255  
256   <macrodef name="build-jar-stats">
257     <sequential>
258       <if>
259         <not>
260           <isset property="org.bedework.jars.built" />
261         </not>
262         <then>
263           <echo message="No jars were checked or built" />
264         </then>
265         <else>
266           <echo message="${org.bedework.jars.checked} jars checked: ${org.bedework.jars.built} built" />
267         </else>
268       </if>
269     </sequential>
270   </macrodef>
271  
272   <!-- This macro builds a single jar file. It just sets defaults for the java
273        compiler then invokes it.
274
275        This is the only place we compile files.
276
277        On entry we require:
278          jar.file              Fully specified name of destination jar file.
279          base.java.sources     Defines the java source files
280          base.class.patternset Defines the java class files
281          base.resource.files   Defines extra resources to go in the jar
282
283        We will copy all files defined by base.java.patternset to a temporary
284        location and compile out of that into a temporary classes location.
285
286        We do that to avoid a problematic feature of the java compilers, the
287        tendency to recompile any referenced sources found on the source path.
288
289        So, if we have all our sources under the directory "src" and compile a
290        single package in that tree, all referenced classes will be compiled,
291        even if they exist in a jar file on the class path.
292
293        The other side-effect is that we might compile and include classes we
294        didn't realise we were compiling.
295
296        The downside is that we need to be very specific about the classes we
297        compile for a package and we might need to put classes in
298        base.java.sources which we don't want in the final jar file.
299
300        On exit we will have created classes in the directory
301           ${jar.temp.classes}
302        and a jar file
303           ${build.jar.file}
304
305        Authors: Mike Douglass   douglm rpi.edu
306   -->
307   <macrodef name="build-jar">
308     <attribute name="module-base"/>
309     <attribute name="jar-file"/>
310     <attribute name="jar-dependency" default=""/>
311     <attribute name="generated-sources" default=""/>
312     <attribute name="property-resources" default=""/>
313    
314     <sequential>
315       <if>
316         <not>
317           <isset property="org.bedework.jars.built" />
318         </not>
319         <then>
320           <var name="org.bedework.jars.built" value="0" />
321           <var name="org.bedework.jars.checked" value="0" />
322         </then>
323       </if>
324      
325       <math result="org.bedework.jars.checked"
326             operand1="${org.bedework.jars.checked}"
327             operation="+" operand2="1" datatype="int"/>
328
329       <if>
330         <equals arg1="@{generated-sources}" arg2="" />
331         <then>
332           <fileset id="buildjar.generated.java.sources" refid="empty.fileset" />
333         </then>
334         <else>
335           <fileset id="buildjar.generated.java.sources" dir="@{generated-sources}" >
336             <include name="org/bedework/**/*.java"/>
337           </fileset>
338         </else>
339       </if>
340
341       <if>
342         <equals arg1="@{property-resources}" arg2="" />
343         <then>
344           <fileset id="buildjar.resource.files" refid="empty.fileset" />
345         </then>
346         <else>
347           <fileset id="buildjar.resource.files" dir="@{property-resources}" >
348             <include name="**/*.properties"/>
349           </fileset>
350         </else>
351       </if>
352
353       <fileset id="buildjar.java.sources" dir="@{module-base}/src" >
354         <include name="**/*.java"/>
355       </fileset>
356
357       <patternset id="base.class.patternset">
358         <include name="**/*.class"/>
359       </patternset>
360
361       <if>
362         <not>
363           <equals arg1="@{jar-dependency}" arg2="" />
364         </not>
365         <then>
366           <var name="build.jar.dependency" value="@{jar-dependency}" />
367         </then>
368       </if>
369      
370       <!--  =================== Compilation Control Options ===============
371         These properties control option settings on the Javac compiler when it
372         is invoked using the <javac> task.
373
374         compile.debug        Should compilation include the debug option?
375         compile.deprecation  Should compilation include the deprecation option?
376         compile.optimize     Should compilation include the optimize option?
377
378         Below are the defaults. They may already be set in the build properties.
379       -->
380
381       <property name="compile.debug" value="true"/>
382       <property name="compile.deprecation" value="false"/>
383       <property name="compile.optimize" value="true"/>
384       <property name="compile.verbose" value="false"/>
385       <property name="compile.listfiles" value="false"/>
386
387       <var name="jar.temp.sources"
388            value="${dist.home}/source" />
389       <var name="jar.temp.classes"
390            value="${dist.home}/classes" />
391
392       <!-- ==============================================================
393             See if the jar is up to date. We recompile if any of the
394             source files or metainf files are newer. We also recompile if
395             any jars on the package classpath are newer.
396            ============================================================== -->
397
398       <noisyMsg message="build.jar.file=@{jar-file}" />
399      
400       <if>
401         <isset property="build.jar.dependency"/>
402         <then>
403           <dirname file="${build.jar.dependency}"
404                    property="dependency.dirname" />
405           <basename file="${build.jar.dependency}"
406                     property="dependency.basename" />
407           <fileset dir="${dependency.dirname}" id="dependency.fileset">
408             <include name="${dependency.basename}"/>
409           </fileset>
410         </then>
411         <else>
412           <fileset refid="empty.fileset" id="dependency.fileset"/>
413         </else>
414       </if>     
415
416       <!-- See if the libraries are later than any classes -->
417
418       <var name="org.bedework.libraries.changed" value="false" />
419      
420       <outofdate outputsources="org.bedework,changed.sources">
421         <sourcefiles>
422           <fileset dir="${lib.dir}">
423              <include name="*.jar"/>
424           </fileset>
425           <!-- This makes almost everything rebuild all the time
426                because it has the generated jars for the current package
427           <path refid="compile.classpath"/>
428           -->
429         </sourcefiles>
430         <targetfiles>
431           <pathelement path="@{jar-file}"/>
432         </targetfiles>
433         <sequential>
434           <var name="org.bedework.libraries.changed" value="true" />
435           <noisyMsg message="**** @{jar-file} needs rebuilding - libraries changed" />
436         </sequential>
437       </outofdate>
438      
439       <noisyMsg message="**** org.bedework,changed.sources = ${org.bedework,changed.sources}" />
440       <noisyMsg message="**** org.bedework.libraries.changed = ${org.bedework.libraries.changed}" />
441
442       <if>
443         <and>
444           <not>
445             <equals arg1="${org.bedework.libraries.changed}" arg2="true" />
446           </not>
447           <uptodate targetfile="@{jar-file}" >
448             <srcfiles refid="buildjar.java.sources" />
449             <srcfiles refid="buildjar.generated.java.sources" />
450             <srcfiles refid="buildjar.resource.files"/>
451             <srcfiles refid="dependency.fileset"/>
452           </uptodate>
453         </and>
454         <then>
455           <noisyMsg message="**** @{jar-file} is up to date" />
456         </then>
457         <else>
458           <noisyMsg message="**** @{jar-file} needs rebuilding" />
459
460           <math result="org.bedework.jars.built"
461                 operand1="${org.bedework.jars.built}"
462                 operation="+" operand2="1" datatype="int"/>
463
464           <!-- Delete jar file -->
465           <delete file="@{jar-file}"/>
466
467           <dirname property="build.jar.dir" file="@{jar-file}"/>
468
469           <mkdir dir="${build.jar.dir}" />
470
471           <!-- ==========================================================
472                             Build the classes
473                ========================================================== -->
474
475           <!-- First copy the sources we are going to compile into a temp
476                directory. -->
477           <delete dir="${jar.temp.sources}" />
478           <mkdir dir="${jar.temp.sources}" />
479          
480           <copy toDir="${jar.temp.sources}">
481             <fileset refid="buildjar.java.sources" />
482             <fileset refid="buildjar.generated.java.sources" />
483             <fileset refid="buildjar.resource.files"/>
484           </copy>
485
486           <mkdir dir="${jar.temp.classes}"/>
487          
488           <debugMsg message="About to build jar @{jar-file}"/>
489           <debugCpid idpar="compile.classpath" />
490
491           <javac srcdir="${jar.temp.sources}"
492                  destdir="${jar.temp.classes}"
493                  debug="${compile.debug}"
494                  verbose="${compile.verbose}"
495                  listfiles="${compile.listfiles}"
496                  deprecation="${compile.deprecation}"
497                  optimize="${compile.optimize}">
498             <classpath refid="compile.classpath"/>
499             <include name="**/*.java"/>
500             <compilerarg value="-nowarn" compiler="jikes" />
501           </javac>
502
503           <!-- ==========================================================
504                             Build jar file
505                ========================================================== -->
506
507           <jar jarfile="@{jar-file}">
508             <fileset dir="${jar.temp.classes}">
509               <patternset refid="base.class.patternset"/>
510             </fileset>
511             <fileset refid="buildjar.resource.files"/>
512           </jar>
513
514           <!-- ==========================================================
515                             Clean up
516                ========================================================== -->
517
518           <delete dir="${jar.temp.sources}" />
519           <delete dir="${jar.temp.classes}"/>
520         </else>
521       </if>
522     </sequential>
523   </macrodef>
524  
525   <macrodef name="infoMsg">
526     <attribute name="message"/>
527     <sequential>
528       <if>
529         <not>
530           <istrue value="${org.bedework.build.silent}" />
531         </not>
532         <then>
533           <echo message="@{message}" />
534         </then>
535       </if>
536     </sequential>
537   </macrodef>
538  
539   <macrodef name="noisyMsg">
540     <attribute name="message"/>
541     <sequential>
542       <if>
543         <istrue value="${org.bedework.build.noisy}" />
544         <then>
545           <echo message="@{message}" />
546         </then>
547       </if>
548     </sequential>
549   </macrodef>
550  
551   <macrodef name="debugMsg">
552     <attribute name="message"/>
553     <sequential>
554       <if>
555         <istrue value="${org.bedework.build.debug}" />
556         <then>
557           <echo message="@{message}" />
558         </then>
559       </if>
560     </sequential>
561   </macrodef>
562  
563   <macrodef name="debugCpid">
564     <attribute name="idpar"/>
565     <sequential>
566       <if>
567         <istrue value="${org.bedework.build.debug}" />
568         <then>
569           <property name="cp" refid="@{idpar}" />
570           <echo message="***************cp: ${cp}"/>
571         </then>
572       </if>
573     </sequential>
574   </macrodef>
575 </project>
Note: See TracBrowser for help on using the browser.