root/trunk/build/buildwar.xml

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

Further changes to the build process.

This allows virtual hosts to be set in the config file for carddav.

Carddav configuration is now rolled into the same config files as the other projects

Small change to webdav error logging

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       <available file="${app.sou.dir}/war/docs" type="dir" />
116       <then>
117         <!-- Add modifed login pages -->
118         <copy todir="${app.dest.docs}/login" failonerror="false" >
119           <fileset dir="${org.bedework.common.resources}/login" />
120           <filterset>
121             <filter token="DISPLAY-NAME" value="${propval.app.display.name}"/>
122           </filterset>
123         </copy>
124       </then>
125     </if>
126
127     <!-- ===============================================================
128          We copy 3 sets of properties.
129
130          First (for struts) are the servlet properties which ends up as
131               classes/servlet.properties
132          Next we copy in a set of generic property files and then with
133          overwrite we copy in a set of base specific files.
134
135          All are updated with new values.
136          =============================================================== -->
137
138     <if>
139       <available file="${app.sou.dir}/war/docs" type="dir" />
140       <then>
141         <copy todir="${app.dest.docs}">
142           <fileset dir="${app.sou.dir}/war/docs" />
143         </copy>
144       </then>
145     </if>
146
147     <!-- ===============================================================
148          Any property files we need for configuration, other than the
149          standard struts file, should be in the "${app.sou.dir}/properties
150          directory. They will be copied into the appropriate place for the
151          war and transformed by the above filter.
152          =============================================================== -->
153
154     <!-- Create the runtime options file -->
155     <mkdir dir="${app.dest.properties}" />
156
157     <if>
158       <available file="${app.sou.dir}/properties" type="dir" />
159       <then>
160         <copy todir="${app.dest.properties}" overwrite="yes" >
161           <fileset dir="${app.sou.dir}/properties"
162                    includes="*.properties"/>
163           <filterset refid="property.filters" />
164         </copy>
165       </then>
166     </if>
167
168     <copy tofile="${app.dest.properties}/options.xml"
169           file="${org.bedework.config.options}" >
170       <filterset>
171         <filter token="RPI-DEBUG" value="${app.debug.val}"/>
172       </filterset>
173       <filterset refid="property.filters" />
174     </copy>
175    
176     <copy tofile="${app.dest.classes}/sysevents.properties"
177           file="${org.bedework.config.sysevents.properties}" />
178
179     <if>
180       <isset property="org.bedework.sou.classpath.properties" />
181       <then>
182         <copy todir="${app.dest.classes}">
183           <fileset dir="${org.bedework.sou.classpath.properties}" />
184           <filterset refid="property.filters" />
185         </copy>
186       </then>
187     </if>
188
189     <if>
190       <isset property="org.bedework.sou.hibernate.properties" />
191       <then>
192         <!-- ===========================================================
193              Add hibernate config.
194              =========================================================== -->
195
196         <debugMsg message="************* Copy hib properties from ${org.bedework.sou.hibernate.properties}" />
197
198         <copy todir="${app.dest.classes}">
199           <fileset dir="${org.bedework.sou.hibernate.properties}/properties" />
200           <filterset refid="property.filters" />
201         </copy>
202    
203         <copy todir="${app.dest.classes}">
204           <fileset dir="${org.bedework.sou.hibernate.properties}/hbms" />
205           <filterset refid="property.filters" />
206         </copy>
207       </then>
208     </if>
209
210     <!-- Make a temp copy of the web.xml file -->
211     <copy tofile="${app.temp.web.xml}" file="${app.web.xml}"
212           overwrite="yes" />
213
214     <antcall target="struts-stuff" inheritRefs="true" />
215
216     <!-- Filter the temp copy of the web.xml file -->
217     <copy tofile="${app.dest.web.xml}"
218           file="${app.temp.web.xml}"
219           overwrite="yes" >
220       <filterset>
221         <filter token="RPI-DEBUG" value="${app.debug.val}"/>
222       </filterset>
223       <filterset refid="property.filters" />
224     </copy>
225
226     <delete file="${app.temp.web.xml}" />
227
228     <!-- Add the context root to the file. Note that newline is required -->
229     <echo file="${org.bedework.global.context.roots}" append="yes">
230 ${propval.app.war.name}.context=${propval.app.context.root}
231     </echo>
232
233     <!-- Add libraries: Platform specific -->
234     <antcall target="addLibs" inheritRefs="true" />
235
236     <!-- Platform specific -->
237     <antcall target="doPlatform" inheritRefs="true" />
238
239     <!-- build the war file or directory -->
240     <mkdir dir="${dist.home}" />
241
242     <!-- may be there as a file or a directory -->
243     <delete file="${app.war.file}" />
244     <delete dir="${app.war.file}" />
245        
246     <if>
247       <or>
248         <not>
249           <isset property="org.bedework.global.wars.zipped" />
250         </not>
251         <istrue value="${org.bedework.global.wars.zipped}"/>
252       </or>
253       <then>
254         <!-- Build a zipped war file -->
255         <war warfile="${app.war.file}"
256              webxml="${app.dest.web.xml}"
257              basedir="${app.dest.war}"
258              excludes="WEB-INF/web.xml" />
259       </then>
260       <else>
261         <!-- Unzipped war file -->
262         <copy todir="${app.war.file}">
263           <fileset dir="${app.dest.war}"  includes="*"/>
264           <filterset refid="property.filters" />
265         </copy>
266       </else>
267     </if>
268   </target>
269
270   <!-- =================================================================
271        If this is a struts app the following gets executed.
272        We create an updated struts-config.xml file and add some jars.
273        ================================================================= -->
274
275   <target name="struts-stuff" if="org.bedework.strutsapp">
276     <!-- Make our own servlet.properties file for struts applications -->
277     <echo file="${app.dest.classes}/servlet.properties" ><![CDATA[#
278 # ========================================================================
279 # This file contains all properties for servlet applications.
280 # It cannot be application specific as the jboss build creates a
281 # single set of resources on the classpath.
282 # ========================================================================
283 #
284
285 # ========================================================================
286 # Properties for the xml/xslt based calendar web applications
287 # ========================================================================
288 #
289 # author Mike Douglass douglm rpi.edu
290
291 # This is only here because the jetspeed portal-struts bridge does not seem to be
292 # passing across the servlet context.
293 #org.bedework.svcicb.sessionAttrName=org.bedework.admin.svcicb.sessionattrname.@APP-NAME@
294
295 # These are required by the Struts framework
296 errors.header=<errors><ul>
297 errors.footer=</ul></errors>
298
299 messages.header=<messages><ul>
300 messages.footer=</ul></messages>
301
302 edu.rpi.sss.util.action.noactionerrors=yes
303
304 applicationResources=<li>Cannot load application resources bundle {0}</li>
305
306 # set the default content type - html for jsp, xml for xml/xslt.
307 #edu.rpi.sss.util.action.contenttype=@DEFAULT-CONTENTTYPE@
308 edu.rpi.sss.util.action.contenttype=text/xml
309
310 edu.rpi.sss.util.error.exc=<li>Exception: {0}</li>
311
312 # Turn nocache headers on. We don't use the standard struts directives
313 # because we need to be able to turn nocache off for a single response.
314 # This gets around an IE problem with delivery of files.
315 edu.rpi.sss.util.action.nocache=yes
316
317 org.bedework.security.prefix=@SECURITY-PREFIX@
318
319 edu.rpi.sss.util.action.logprefix=@APP-NAME@
320
321 # Roles we need to know about - init action uses these
322 # (Not using roles in the current system)
323 #org.bedework.role.admin=@SECURITY-PREFIX@.admin
324 #org.bedework.role.contentadmin=@SECURITY-PREFIX@.contentadmin
325 #org.bedework.role.alert=@SECURITY-PREFIX@.alerts
326 #org.bedework.role.owner=@SECURITY-PREFIX@.owner
327 ]]></echo>
328
329     <!-- Replace the tokens -->
330     <replace file="${app.dest.classes}/servlet.properties">
331       <replacefilter token="@SECURITY-PREFIX@"
332                      value="${propval.app.security.prefix}" />
333       <replacefilter token="@APP-NAME@"
334                      value="${propval.app.name}" />
335       <replacefilter token="@DEFAULT-CONTENTTYPE@"
336                      value="${propval.app.default.contenttype}" />
337     </replace>
338      
339     <!-- Copy a dummy startup file into the war. -->
340     <copy todir="${app.dest.war}">
341       <fileset dir="${app.sou.dir}/war/" includes="setup.do" />
342     </copy>
343
344     <copy todir="${app.dest.webinf}"
345           file="${app.sou.dir}/war/WEB-INF/struts-config.xml"/>
346
347     <mkdir  dir="${app.dest.webinf}/tlds"/>
348     <copy todir="${app.dest.webinf}/tlds" >
349       <fileset dir="${org.bedework.struts.tlds}">
350         <include name="*"/>
351       </fileset>
352     </copy>
353
354     <if>
355       <isset property="org.bedework.global.portal.platform" />
356       <then>
357         <antcall target="doPortal" inheritRefs="true" />
358       </then>
359     </if>
360
361   </target>
362 </project>
Note: See TracBrowser for help on using the browser.