root/trunk/build/buildwar.xml

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

Allow specification of customized login files.

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     <copy tofile="${app.dest.classes}/sysevents.properties"
189           file="${org.bedework.config.sysevents.properties}" />
190
191     <if>
192       <isset property="org.bedework.sou.classpath.properties" />
193       <then>
194         <copy todir="${app.dest.classes}">
195           <fileset dir="${org.bedework.sou.classpath.properties}" />
196           <filterset refid="property.filters" />
197         </copy>
198       </then>
199     </if>
200
201     <if>
202       <isset property="org.bedework.sou.hibernate.properties" />
203       <then>
204         <!-- ===========================================================
205              Add hibernate config.
206              =========================================================== -->
207
208         <debugMsg message="************* Copy hib properties from ${org.bedework.sou.hibernate.properties}" />
209
210         <copy todir="${app.dest.classes}">
211           <fileset dir="${org.bedework.sou.hibernate.properties}/properties" />
212           <filterset refid="property.filters" />
213         </copy>
214    
215         <copy todir="${app.dest.classes}">
216           <fileset dir="${org.bedework.sou.hibernate.properties}/hbms" />
217           <filterset refid="property.filters" />
218         </copy>
219       </then>
220     </if>
221
222     <!-- Make a temp copy of the web.xml file -->
223     <copy tofile="${app.temp.web.xml}" file="${app.web.xml}"
224           overwrite="yes" />
225
226     <antcall target="struts-stuff" inheritRefs="true" />
227
228     <!-- Filter the temp copy of the web.xml file -->
229     <copy tofile="${app.dest.web.xml}"
230           file="${app.temp.web.xml}"
231           overwrite="yes" >
232       <filterset>
233         <filter token="RPI-DEBUG" value="${app.debug.val}"/>
234       </filterset>
235       <filterset refid="property.filters" />
236     </copy>
237
238     <delete file="${app.temp.web.xml}" />
239
240     <!-- Add the context root to the file. Note that newline is required -->
241     <echo file="${org.bedework.global.context.roots}" append="yes">
242 ${propval.app.war.name}.context=${propval.app.context.root}
243     </echo>
244
245     <!-- Add libraries: Platform specific -->
246     <antcall target="addLibs" inheritRefs="true" />
247
248     <!-- Platform specific -->
249     <antcall target="doPlatform" inheritRefs="true" />
250
251     <!-- build the war file or directory -->
252     <mkdir dir="${dist.home}" />
253
254     <!-- may be there as a file or a directory -->
255     <delete file="${app.war.file}" />
256     <delete dir="${app.war.file}" />
257        
258     <if>
259       <or>
260         <not>
261           <isset property="org.bedework.global.wars.zipped" />
262         </not>
263         <istrue value="${org.bedework.global.wars.zipped}"/>
264       </or>
265       <then>
266         <!-- Build a zipped war file -->
267         <war warfile="${app.war.file}"
268              webxml="${app.dest.web.xml}"
269              basedir="${app.dest.war}"
270              excludes="WEB-INF/web.xml" />
271       </then>
272       <else>
273         <!-- Unzipped war file -->
274         <copy todir="${app.war.file}">
275           <fileset dir="${app.dest.war}"  includes="*"/>
276           <filterset refid="property.filters" />
277         </copy>
278       </else>
279     </if>
280   </target>
281
282   <!-- =================================================================
283        If this is a struts app the following gets executed.
284        We create an updated struts-config.xml file and add some jars.
285        ================================================================= -->
286
287   <target name="struts-stuff" if="org.bedework.strutsapp">
288     <!-- Make our own servlet.properties file for struts applications -->
289     <echo file="${app.dest.classes}/servlet.properties" ><![CDATA[#
290 # ========================================================================
291 # This file contains all properties for servlet applications.
292 # It cannot be application specific as the jboss build creates a
293 # single set of resources on the classpath.
294 # ========================================================================
295 #
296
297 # ========================================================================
298 # Properties for the xml/xslt based calendar web applications
299 # ========================================================================
300 #
301 # author Mike Douglass douglm rpi.edu
302
303 # This is only here because the jetspeed portal-struts bridge does not seem to be
304 # passing across the servlet context.
305 #org.bedework.svcicb.sessionAttrName=org.bedework.admin.svcicb.sessionattrname.@APP-NAME@
306
307 # These are required by the Struts framework
308 errors.header=<errors><ul>
309 errors.footer=</ul></errors>
310
311 messages.header=<messages><ul>
312 messages.footer=</ul></messages>
313
314 edu.rpi.sss.util.action.noactionerrors=yes
315
316 applicationResources=<li>Cannot load application resources bundle {0}</li>
317
318 # set the default content type - html for jsp, xml for xml/xslt.
319 #edu.rpi.sss.util.action.contenttype=@DEFAULT-CONTENTTYPE@
320 edu.rpi.sss.util.action.contenttype=text/xml
321
322 edu.rpi.sss.util.error.exc=<li>Exception: {0}</li>
323
324 # Turn nocache headers on. We don't use the standard struts directives
325 # because we need to be able to turn nocache off for a single response.
326 # This gets around an IE problem with delivery of files.
327 edu.rpi.sss.util.action.nocache=yes
328
329 org.bedework.security.prefix=@SECURITY-PREFIX@
330
331 edu.rpi.sss.util.action.logprefix=@APP-NAME@
332
333 # Roles we need to know about - init action uses these
334 # (Not using roles in the current system)
335 #org.bedework.role.admin=@SECURITY-PREFIX@.admin
336 #org.bedework.role.contentadmin=@SECURITY-PREFIX@.contentadmin
337 #org.bedework.role.alert=@SECURITY-PREFIX@.alerts
338 #org.bedework.role.owner=@SECURITY-PREFIX@.owner
339 ]]></echo>
340
341     <!-- Replace the tokens -->
342     <replace file="${app.dest.classes}/servlet.properties">
343       <replacefilter token="@SECURITY-PREFIX@"
344                      value="${propval.app.security.prefix}" />
345       <replacefilter token="@APP-NAME@"
346                      value="${propval.app.name}" />
347       <replacefilter token="@DEFAULT-CONTENTTYPE@"
348                      value="${propval.app.default.contenttype}" />
349     </replace>
350      
351     <!-- Copy a dummy startup file into the war. -->
352     <copy todir="${app.dest.war}">
353       <fileset dir="${app.sou.dir}/war/" includes="setup.do" />
354     </copy>
355
356     <copy todir="${app.dest.webinf}"
357           file="${app.sou.dir}/war/WEB-INF/struts-config.xml"/>
358
359     <mkdir  dir="${app.dest.webinf}/tlds"/>
360     <copy todir="${app.dest.webinf}/tlds" >
361       <fileset dir="${org.bedework.struts.tlds}">
362         <include name="*"/>
363       </fileset>
364     </copy>
365
366     <if>
367       <isset property="org.bedework.global.portal.platform" />
368       <then>
369         <antcall target="doPortal" inheritRefs="true" />
370       </then>
371     </if>
372
373   </target>
374 </project>
Note: See TracBrowser for help on using the browser.