root/trunk/build/buildwar.xml

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

Suppress some warnings from compiler.

Move the config log4j.xml into the .defaults directory

Change the way extra properties are handled - only used by synch

Line 
1 <?xml version="1.0"?>
2
3 <!-- ===================================================================
4      This file is called by other build files to create web applications.
5
6      It is assumed that no changes will be made to this file. It should be
7      possible to make all changes needed by modifying the configuration
8      properties or a bedework.build.proeprties file
9
10      An unwrapped web application will be built in the temp directory
11      and a war and ear file will be left in the dist directory.
12
13      Properties which must be defined on entry, apart from those described
14      in the main build file are:
15     app.root.dir       Location of the root directory for the apps
16     app.sou.dir        Location of the application skeleton,
17     app.name           Name of the application. This wil be used to determine
18                        the name of the file containing the rest of the
19                        application properties, the directory we build in
20                        and the name of war and ear files.
21      These should be defined in the build properties for the application.
22
23      It is possible to define any of the app.dest properties below to override
24      the location of destination files.
25
26      In the directory
27         ${apps.sou.dir}
28      we expect an application skeleton formatted like a web-application
29      For the purposes of this build it should contain a
30      structure like
31               war - docs    (contains jsp and html for this app)
32                     WEB-INF - struts-config.xml
33                               web.xml
34                               jboss-web.xml (for jboss only)
35
36      Authors: Mike Douglass
37      =================================================================== -->
38
39 <project name="bedework.buildwar" default="build" >
40   <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
41
42   <import file="${build.dir}/buildfilters.xml" />
43
44   <if>
45     <isset property="org.bedework.global.portal.platform" />
46     <then>
47       <import file="${build.dir}/portals/${org.bedework.global.portal.platform}War.xml" />
48     </then>
49   </if>
50
51   <import file="${build.dir}/platforms/${org.bedework.global.deploy.platform}War.xml" />
52
53   <target name="init" depends="init.common">
54     <if>
55       <isset property="org.bedework.global.build.ear" />
56       <then>
57         <!-- Properties all go into a single jar file at termination -->
58         <property name="app.dest.classes"
59                   location="${org.bedework.ear.properties.dir}" />
60       </then>
61       <else>
62         <!-- Properties in the war file -->
63         <property name="app.dest.classes"
64                   location="${app.dest.webinf}/classes" />
65       </else>
66     </if>
67     <property name="app.dest.properties"
68               location="${app.dest.classes}/properties/${org.bedework.deployment.name}" />
69   </target>
70
71   <target name="init.common">
72     <!-- Destinations - where we build an unwrapped war -->
73     <property name="app.dest.war"
74               location="${org.bedework.temp.wars.home}/${propval.app.war.name}.war" />
75     <property name="app.dest.docs"
76               location="${app.dest.war}/docs" />
77     <property name="app.dest.webinf"
78               location="${app.dest.war}/WEB-INF" />
79     <property name="app.dest.metainf"
80               location="${app.dest.war}/META-INF" />
81
82     <!--temp web.xml location  -->
83     <property name="app.temp.web.xml"
84               location="${app.dest.webinf}/tempweb.xml" />
85
86     <!--final web.xml location  -->
87     <property name="app.dest.web.xml"
88               location="${app.dest.webinf}/web.xml" />
89
90     <property name="app.war.file"
91               location="${dist.home}/${propval.app.war.name}.war" />
92
93     <!-- default web.xml -->
94     <property name="propval.app.web.xml"
95               value="war/WEB-INF/web.xml" />
96
97               <!--
98     <property name="app.web.xml"
99               location="${propval.app.web.xml}" />
100               -->
101     <resolveFile name="app.web.xml"
102                  file="${propval.app.web.xml}"
103                  base="${app.sou.dir}"/>
104
105     <property name="app.sou.properties"
106               location="${app.sou.dir}/war/WEB-INF/classes/servlet.properties" />
107   </target>
108
109   <target name="build" depends="init">
110     <infoMsg message="* =========== Building war ${propval.app.war.name}" />
111
112     <delete dir="${app.dest.war}" />
113
114     <if>
115       <isset property="propval.app.login.directory" />
116       <then>
117         <fileset dir="${propval.app.login.directory}"
118                  id="org.bedework.login.fileset" />
119       </then>
120       <else>
121         <fileset dir="${org.bedework.common.resources}/login"
122                  id="org.bedework.login.fileset" />
123       </else>
124     </if>
125
126     <if>
127       <available file="${app.sou.dir}/war/docs" type="dir" />
128       <then>
129         <!-- Add modifed login pages -->
130         <copy todir="${app.dest.docs}/login" failonerror="false" >
131           <fileset refid="org.bedework.login.fileset" />
132           <filterset>
133             <filter token="DISPLAY-NAME" value="${propval.app.display.name}"/>
134           </filterset>
135         </copy>
136       </then>
137     </if>
138
139     <!-- ===============================================================
140          We copy 3 sets of properties.
141
142          First (for struts) are the servlet properties which ends up as
143               classes/servlet.properties
144          Next we copy in a set of generic property files and then with
145          overwrite we copy in a set of base specific files.
146
147          All are updated with new values.
148          =============================================================== -->
149
150     <if>
151       <available file="${app.sou.dir}/war/docs" type="dir" />
152       <then>
153         <copy todir="${app.dest.docs}">
154           <fileset dir="${app.sou.dir}/war/docs" />
155         </copy>
156       </then>
157     </if>
158
159     <!-- ===============================================================
160          Any property files we need for configuration, other than the
161          standard struts file, should be in the "${app.sou.dir}/properties
162          directory. They will be copied into the appropriate place for the
163          war and transformed by the above filter.
164          =============================================================== -->
165
166     <!-- Create the runtime options file -->
167     <mkdir dir="${app.dest.properties}" />
168
169     <if>
170       <available file="${app.sou.dir}/properties" type="dir" />
171       <then>
172         <copy todir="${app.dest.properties}" overwrite="yes" >
173           <fileset dir="${app.sou.dir}/properties"
174                    includes="*.properties"/>
175           <filterset refid="property.filters" />
176         </copy>
177       </then>
178     </if>
179
180     <copy tofile="${app.dest.properties}/options.xml"
181           file="${org.bedework.config.options}" >
182       <filterset>
183         <filter token="RPI-DEBUG" value="${app.debug.val}"/>
184       </filterset>
185       <filterset refid="property.filters" />
186     </copy>
187    
188     <if>
189       <isset property="org.bedework.extra.properties" />
190       <then>
191         <copy todir="${app.dest.properties}">
192           <filelist dir="${org.bedework.extra.properties.dir}"
193                     files="${org.bedework.extra.properties}"/>
194           <filterset refid="property.filters" />
195         </copy>
196       </then>
197     </if>
198    
199     <copy tofile="${app.dest.classes}/sysevents.properties"
200           file="${org.bedework.config.sysevents.properties}" />
201
202     <if>
203       <isset property="org.bedework.sou.classpath.properties" />
204       <then>
205         <copy todir="${app.dest.classes}">
206           <fileset dir="${org.bedework.sou.classpath.properties}" />
207           <filterset refid="property.filters" />
208         </copy>
209       </then>
210     </if>
211
212     <if>
213       <isset property="org.bedework.sou.hibernate.properties" />
214       <then>
215         <!-- ===========================================================
216              Add hibernate config.
217              =========================================================== -->
218
219         <debugMsg message="************* Copy hib properties from ${org.bedework.sou.hibernate.properties}" />
220
221         <copy todir="${app.dest.classes}">
222           <fileset dir="${org.bedework.sou.hibernate.properties}/properties" />
223           <filterset refid="property.filters" />
224         </copy>
225    
226         <copy todir="${app.dest.classes}">
227           <fileset dir="${org.bedework.sou.hibernate.properties}/hbms" />
228           <filterset refid="property.filters" />
229         </copy>
230       </then>
231     </if>
232
233     <!-- Make a temp copy of the web.xml file -->
234     <copy tofile="${app.temp.web.xml}" file="${app.web.xml}"
235           overwrite="yes" />
236
237     <antcall target="struts-stuff" inheritRefs="true" />
238
239     <!-- Filter the temp copy of the web.xml file -->
240     <copy tofile="${app.dest.web.xml}"
241           file="${app.temp.web.xml}"
242           overwrite="yes" >
243       <filterset>
244         <filter token="RPI-DEBUG" value="${app.debug.val}"/>
245       </filterset>
246       <filterset refid="property.filters" />
247     </copy>
248
249     <delete file="${app.temp.web.xml}" />
250
251     <!-- Add the context root to the file. Note that newline is required -->
252     <echo file="${org.bedework.global.context.roots}" append="yes">
253 ${propval.app.war.name}.context=${propval.app.context.root}
254     </echo>
255
256     <!-- Add libraries: Platform specific -->
257     <antcall target="addLibs" inheritRefs="true" />
258
259     <!-- Platform specific -->
260     <antcall target="doPlatform" inheritRefs="true" />
261
262     <!-- build the war file or directory -->
263     <mkdir dir="${dist.home}" />
264
265     <!-- may be there as a file or a directory -->
266     <delete file="${app.war.file}" />
267     <delete dir="${app.war.file}" />
268        
269     <if>
270       <or>
271         <not>
272           <isset property="org.bedework.global.wars.zipped" />
273         </not>
274         <istrue value="${org.bedework.global.wars.zipped}"/>
275       </or>
276       <then>
277         <!-- Build a zipped war file -->
278         <war warfile="${app.war.file}"
279              webxml="${app.dest.web.xml}"
280              basedir="${app.dest.war}"
281              excludes="WEB-INF/web.xml" />
282       </then>
283       <else>
284         <!-- Unzipped war file -->
285         <copy todir="${app.war.file}">
286           <fileset dir="${app.dest.war}"  includes="*"/>
287           <filterset refid="property.filters" />
288         </copy>
289       </else>
290     </if>
291   </target>
292
293   <!-- =================================================================
294        If this is a struts app the following gets executed.
295        We create an updated struts-config.xml file and add some jars.
296        ================================================================= -->
297
298   <target name="struts-stuff" if="org.bedework.strutsapp">
299     <!-- Make our own servlet.properties file for struts applications -->
300     <echo file="${app.dest.classes}/servlet.properties" ><![CDATA[#
301 # ========================================================================
302 # This file contains all properties for servlet applications.
303 # It cannot be application specific as the jboss build creates a
304 # single set of resources on the classpath.
305 # ========================================================================
306 #
307
308 # ========================================================================
309 # Properties for the xml/xslt based calendar web applications
310 # ========================================================================
311 #
312 # author Mike Douglass douglm rpi.edu
313
314 # This is only here because the jetspeed portal-struts bridge does not seem to be
315 # passing across the servlet context.
316 #org.bedework.svcicb.sessionAttrName=org.bedework.admin.svcicb.sessionattrname.@APP-NAME@
317
318 # These are required by the Struts framework
319 errors.header=<errors><ul>
320 errors.footer=</ul></errors>
321
322 messages.header=<messages><ul>
323 messages.footer=</ul></messages>
324
325 edu.rpi.sss.util.action.noactionerrors=yes
326
327 applicationResources=<li>Cannot load application resources bundle {0}</li>
328
329 # set the default content type - html for jsp, xml for xml/xslt.
330 #edu.rpi.sss.util.action.contenttype=@DEFAULT-CONTENTTYPE@
331 edu.rpi.sss.util.action.contenttype=text/xml
332
333 edu.rpi.sss.util.error.exc=<li>Exception: {0}</li>
334
335 # Turn nocache headers on. We don't use the standard struts directives
336 # because we need to be able to turn nocache off for a single response.
337 # This gets around an IE problem with delivery of files.
338 edu.rpi.sss.util.action.nocache=yes
339
340 org.bedework.security.prefix=@SECURITY-PREFIX@
341
342 edu.rpi.sss.util.action.logprefix=@APP-NAME@
343
344 # Roles we need to know about - init action uses these
345 # (Not using roles in the current system)
346 #org.bedework.role.admin=@SECURITY-PREFIX@.admin
347 #org.bedework.role.contentadmin=@SECURITY-PREFIX@.contentadmin
348 #org.bedework.role.alert=@SECURITY-PREFIX@.alerts
349 #org.bedework.role.owner=@SECURITY-PREFIX@.owner
350 ]]></echo>
351
352     <!-- Replace the tokens -->
353     <replace file="${app.dest.classes}/servlet.properties">
354       <replacefilter token="@SECURITY-PREFIX@"
355                      value="${propval.app.security.prefix}" />
356       <replacefilter token="@APP-NAME@"
357                      value="${propval.app.name}" />
358       <replacefilter token="@DEFAULT-CONTENTTYPE@"
359                      value="${propval.app.default.contenttype}" />
360     </replace>
361      
362     <!-- Copy a dummy startup file into the war. -->
363     <copy todir="${app.dest.war}">
364       <fileset dir="${app.sou.dir}/war/" includes="setup.do" />
365     </copy>
366
367     <copy todir="${app.dest.webinf}"
368           file="${app.sou.dir}/war/WEB-INF/struts-config.xml"/>
369
370     <mkdir  dir="${app.dest.webinf}/tlds"/>
371     <copy todir="${app.dest.webinf}/tlds" >
372       <fileset dir="${org.bedework.struts.tlds}">
373         <include name="*"/>
374       </fileset>
375     </copy>
376
377     <if>
378       <isset property="org.bedework.global.portal.platform" />
379       <then>
380         <antcall target="doPortal" inheritRefs="true" />
381       </then>
382     </if>
383
384   </target>
385 </project>
Note: See TracBrowser for help on using the browser.