root/releases/bedework-3.8/build/buildTools/deftasks.xml

Revision 3454 (checked in by douglm, 1 year ago)

Remove unused property from bedework/build.xml

Add quickstart-clean target to deftasks.xml

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