root/releases/bedework-3.8/build/buildwar.xml

Revision 3612 (checked in by douglm, 10 months ago)

Change to correctly deploy spring web apps

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