root/trunk/build/buildwar.xml

Revision 1306 (checked in by douglm, 6 years ago)

Additions to filtering support

Some changes to build process to better support portals.

Caldav fixes

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     cal.j2ee           Defined if this is a j2ee application
22     cal.j2ee.jboss     Defined if this is a jboss application
23     cal.strutsapp      Defined if this is a struts application
24      These should be defined in the build properties for the application.
25
26      It is possible to define any of the app.dest properties below to override
27      the location of destination files.
28
29      In the directory
30         ${apps.sou.dir}
31      we expect an application skeleton formatted like a web-application
32      For the purposes of this build it should contain a
33      structure like
34               war - docs    (contains jsp and html for this app)
35                     WEB-INF - struts-config.xml
36                               web.xml
37                               jboss-web.xml (for jboss only)
38
39      Authors: Mike Douglass
40      =================================================================== -->
41
42 <project name="bedework.buildwar" default="build" >
43   <import file="${build.dir}/buildfilters.xml" />
44
45   <target name="init" depends="init.common,init.j2ee,init.standalone" />
46
47   <target name="init.common">
48     <!-- Load the location of the libraries -->
49     <property file="${org.bedework.project.bedework}/build/libjars.properties" />
50
51     <!-- Destinations - where we build an unwrapped war -->
52     <property name="app.dest.war"
53               location="${org.bedework.temp.wars.home}/${propval.app.war.name}.war" />
54     <property name="app.dest.docs"
55               location="${app.dest.war}/docs" />
56     <property name="app.dest.webinf"
57               location="${app.dest.war}/WEB-INF" />
58     <property name="app.dest.metainf"
59               location="${app.dest.war}/META-INF" />
60     <property name="app.dest.classes"
61               location="${app.dest.webinf}/classes" />
62     <property name="app.dest.properties"
63               location="${app.dest.classes}/properties/calendar" />
64
65     <!--temp web.xml location  -->
66     <property name="app.temp.web.xml"
67               location="${app.dest.webinf}/tempweb.xml" />
68
69     <!--final web.xml location  -->
70     <property name="app.dest.web.xml"
71               location="${app.dest.webinf}/web.xml" />
72
73     <property name="app.war.file"
74               location="${dist.home}/${propval.app.war.name}.war" />
75
76     <!-- default web.xml -->
77     <property name="propval.app.web.xml"
78               value="war/WEB-INF/web.xml" />
79
80               <!--
81     <property name="app.web.xml"
82               location="${propval.app.web.xml}" />
83               -->
84     <resolveFile name="app.web.xml"
85                  file="${propval.app.web.xml}"
86                  base="${app.sou.dir}"/>
87
88     <property name="app.sou.properties"
89               location="${app.sou.dir}/war/WEB-INF/classes/servlet.properties" />
90   </target>
91
92   <target name="init.standalone" if="org.bedework.global.build.standalone.app">
93
94     <property name="app.dest.lib"
95               location="${app.dest.webinf}/lib" />
96   </target>
97
98   <target name="init.j2ee" if="org.bedework.global.j2ee.platform">
99     <property name="app.dest.lib"
100               location="${org.bedework.temp.dir}/earlib" />
101   </target>
102
103   <target name="build" depends="init">
104     <delete dir="${app.dest.war}" />
105
106     <!-- Add modifed login pages -->
107     <copy todir="${app.dest.docs}/login" failonerror="false" >
108       <fileset dir="${org.bedework.common.resources}/login" />
109       <filterset>
110         <filter token="DISPLAY-NAME" value="${propval.app.display.name}"/>
111       </filterset>
112     </copy>
113
114     <!-- ===============================================================
115          We copy 3 sets of properties.
116
117          First (for struts) are the servlet properties which ends up as
118               classes/servlet.properties
119          Next we copy in a set of generic property files and then with
120          overwrite we copy in a set of base specific files.
121
122          All are updated with new values.
123          =============================================================== -->
124
125     <available file="${app.sou.dir}/properties" type="dir"
126                property="org.bedework.properties.dir.exists" />
127
128     <available file="${app.sou.properties}" type="file"
129                property="org.bedework.servlet.properties.exists" />
130
131     <available file="${app.sou.dir}/war/docs" type="dir"
132                property="org.bedework.war.docs.exists" />
133
134     <antcall target="copy.properties" inheritRefs="true" />
135     <antcall target="copy.servlet.properties" inheritRefs="true" />
136     <antcall target="copy.war.docs" inheritRefs="true" />
137
138     <!-- Create the env.properties file -->
139     <mkdir dir="${app.dest.properties}" />
140
141     <copy tofile="${app.dest.properties}/env.properties"
142           file="${org.bedework.config.properties}" />
143
144     <copy tofile="${app.dest.properties}/options.xml"
145           file="${org.bedework.config.options}" >
146       <filterset>
147         <filter token="RPI-DEBUG" value="${app.debug.val}"/>
148       </filterset>
149       <filterset refid="property.filters" />
150     </copy>
151
152     <!-- Make a temp copy of the web.xml file -->
153     <copy tofile="${app.temp.web.xml}" file="${app.web.xml}"
154           overwrite="yes" />
155
156     <antcall target="struts-stuff" inheritRefs="true" />
157
158     <!-- Filter the temp copy of the web.xml file -->
159     <copy tofile="${app.dest.web.xml}"
160           file="${app.temp.web.xml}"
161           overwrite="yes" >
162       <filterset>
163         <filter token="RPI-DEBUG" value="${app.debug.val}"/>
164       </filterset>
165       <filterset refid="property.filters" />
166     </copy>
167
168     <delete file="${app.temp.web.xml}" />
169
170     <!-- ===============================================================
171          Add hibernate jars and property files from calendar api.
172          =============================================================== -->
173
174     <copy todir="${app.dest.classes}">
175       <fileset dir="${org.bedework.project.calendarapi}/calCore/resources/properties" />
176       <filterset refid="property.filters" />
177     </copy>
178
179     <copy todir="${app.dest.classes}">
180       <fileset dir="${org.bedework.project.calendarapi}/calCore/resources/hbms" />
181       <filterset refid="property.filters" />
182     </copy>
183
184     <copy todir="${app.dest.lib}">
185       <fileset dir="${hibernate.jars.dir}">
186         <include name="*.jar"/>
187       </fileset>
188     </copy>
189
190     <antcall target="jboss-stuff" inheritRefs="true" />
191     <antcall target="bexchange-stuff" inheritRefs="true" />
192     <antcall target="domino-stuff" inheritRefs="true" />
193     <antcall target="google-stuff" inheritRefs="true" />
194
195     <!-- ===============================================================
196          Any jar files required
197          =============================================================== -->
198
199     <copy todir="${app.dest.lib}" overwrite="yes">
200       <fileset dir="${bin.home}">
201         <!-- jars from sub-projects needed by all -->
202         <include name="rpiaccess*.jar"/>
203         <include name="rpiutil*.jar"/>
204         <include name="bw-davdefs*.jar"/>
205         <include name="bw-davio*.jar"/>
206
207         <!-- Calendar api jars -->
208         <include name="bw-apiutil*.jar"/>
209         <include name="bw-calcore*.jar"/>
210         <include name="bw-calcorei*.jar"/>
211         <include name="bw-calenv*.jar"/>
212         <include name="bw-calfacade*.jar"/>
213         <include name="bw-calsvc*.jar"/>
214         <include name="bw-calsvci*.jar"/>
215         <include name="bw-icalendar*.jar"/>
216         <include name="bw-locale*.jar"/>
217         <include name="bw-logging*.jar"/>
218
219         <!-- Common jars for web apps -->
220         <include name="bw-appcommon*.jar"/>
221       </fileset>
222     </copy>
223
224      <!-- any extra bin files-->
225     <copy todir="${app.dest.lib}" >
226       <fileset refid="app.bin.files" />
227     </copy>
228
229     <!-- Some more standard libs -->
230     <if>
231       <not>
232         <isset property="org.bedework.build.for.jboss"/>
233       </not>
234       <then>
235         <copy todir="${app.dest.lib}" file="${log4j.jar}"/>
236       </then>
237     </if>
238     <copy todir="${app.dest.lib}" file="${lucene.core.jar}"/>
239     <copy todir="${app.dest.lib}" file="${lucene.misc.jar}"/>
240     <copy todir="${app.dest.lib}" file="${ical4j.jar}"/>
241     <copy todir="${app.dest.lib}" file="${commons-codec.jar}"/>
242     <copy todir="${app.dest.lib}" file="${commons-collections.jar}"/>
243     <copy todir="${app.dest.lib}" file="${commons-httpclient.jar}"/>
244     <copy todir="${app.dest.lib}" file="${commons-lang.jar}"/>
245     <copy todir="${app.dest.lib}" file="${commons-ssl.jar}"/>
246
247
248     <!-- add the jdbcdriver if defined -->
249     <antcall target="add.jdbcdriver" inheritRefs="true" />
250
251     <!-- tomcat -->
252     <antcall target="add.tomcat" inheritRefs="true" />
253
254      <!-- any extra lib files-->
255     <copy todir="${app.dest.lib}" >
256       <fileset refid="app.lib.files" />
257       <!-- <fileset refid="app.temp.lib.files" /> -->
258     </copy>
259
260     <!-- build the war file -->
261     <mkdir dir="${dist.home}" />
262     <delete file="${app.war.file}" />
263
264     <war warfile="${app.war.file}"
265          webxml="${app.dest.web.xml}"
266          basedir="${app.dest.war}"
267          excludes="WEB-INF/web.xml" />
268   </target>
269
270   <target name="add.jdbcdriver" if="app.jdbcdriver.jar">
271     <copy todir="${app.dest.lib}" file="${app.jdbcdriver.jar}"/>
272   </target>
273
274   <target name="add.tomcat" if="org.bedework.global.deploy.on.tomcat">
275     <property name="propval.app.tomcat.context.xml"
276               location="${app.sou.dir}/war/META-INF/context.xml" />
277     <resolveFile name="app.tomcat.context.xml"
278                  file="${propval.app.tomcat.context.xml}"
279                  base="${app.sou.dir}"/>
280
281     <copy tofile="${app.dest.metainf}/context.xml"
282           file="${app.tomcat.context.xml}"
283           overwrite="yes" >
284       <filterset refid="property.filters" />
285     </copy>
286   </target>
287
288   <target name="copy.properties" if="org.bedework.properties.dir.exists">
289     <!-- ===============================================================
290          Any property files we need for configuration, other than the
291          standard struts file, should be in the "${app.sou.dir}/properties
292          directory. They will be copied into the appropriate place for the
293          war and transformed by the above filter.
294          =============================================================== -->
295     <copy todir="${app.dest.properties}" overwrite="yes" >
296       <fileset dir="${app.sou.dir}/properties"
297                includes="*.properties"/>
298       <filterset refid="property.filters" />
299     </copy>
300   </target>
301
302   <target name="copy.servlet.properties" if="org.bedework.servlet.properties.exists">
303     <copy tofile="${app.dest.classes}/servlet.properties" file="${app.sou.properties}">
304       <filterset refid="property.filters" />
305     </copy>
306   </target>
307
308   <target name="copy.war.docs" if="org.bedework.war.docs.exists">
309     <copy todir="${app.dest.docs}">
310       <fileset dir="${app.sou.dir}/war/docs" />
311     </copy>
312   </target>
313
314   <target name="bexchange-stuff" if="org.bedework.build.caldav.bexchange">
315     <copy tofile="${app.dest.properties}/timezones.xml"
316           file="${org.bedework.project.bedework}/docs/bwtimezones.xml" />
317   </target>
318
319   <target name="domino-stuff" if="org.bedework.build.caldav.domino">
320     <copy tofile="${app.dest.properties}/timezones.xml"
321           file="${org.bedework.project.bedework}/docs/bwtimezones.xml" />
322   </target>
323
324   <target name="google-stuff" if="org.bedework.build.caldav.google">
325     <copy todir="${app.dest.lib}">
326       <fileset dir="${google.dir}">
327         <include name="*.jar"/>
328       </fileset>
329     </copy>
330
331     <copy tofile="${app.dest.properties}/timezones.xml"
332           file="${org.bedework.project.bedework}/docs/bwtimezones.xml" />
333   </target>
334
335   <!-- =================================================================
336        If this is a struts app the following gets executed.
337        We create an updated struts-config.xml file and add some jars.
338        ================================================================= -->
339
340   <target name="struts-stuff" if="org.bedework.strutsapp">
341     <!-- Copy a dummy startup file into the war. -->
342     <copy todir="${app.dest.war}">
343       <fileset dir="${app.sou.dir}/war/" includes="setup.do" />
344     </copy>
345
346     <copy todir="${app.dest.webinf}"
347           file="${app.sou.dir}/war/WEB-INF/struts-config.xml"/>
348
349     <mkdir  dir="${app.dest.webinf}/tlds"/>
350     <copy todir="${app.dest.webinf}/tlds" >
351       <fileset dir="${struts.tlds.dir}">
352         <include name="*"/>
353       </fileset>
354     </copy>
355     <copy todir="${app.dest.webinf}/tlds" >
356       <fileset dir="${org.bedework.default.lib}/tlds">
357         <include name="*"/>
358       </fileset>
359     </copy>
360
361     <if>
362       <not>
363         <isset property="xalan.in.tomcat.common.endorsed" />
364       </not>
365       <then>
366         <copy todir="${app.dest.lib}" file="${xalan.jar}"/>
367       </then>
368     </if>
369
370     <if>
371       <isset property="org.bedework.global.portal.platform" />
372       <then>
373         <!-- Add common portlet files -->
374
375         <copy todir="${app.dest.lib}" >
376           <fileset dir="${portals-bridges.jars.dir}">
377             <include name="*.jar"/>
378           </fileset>
379         </copy>
380
381         <!-- Use generic bedework portlet tld -->
382         <copy todir="${app.dest.webinf}/tlds"
383               overwrite="yes"
384               failonerror="no" >
385           <fileset dir="${app.root.dir}/resources/portlet" >
386             <include name="*.tld"/>
387           </fileset>
388         </copy>
389
390         <copy todir="${app.dest.webinf}"
391               file="${org.bedework.deploy.type.dir}/portlet/struts-portlet-config.xml"
392               overwrite="yes"
393               failonerror="no" />
394
395         <copy todir="${app.dest.webinf}"
396               file="${org.bedework.deploy.type.dir}/portlet/portlet.xml"
397               overwrite="yes"
398               failonerror="no" >
399           <filterset refid="property.filters" />
400         </copy>
401
402         <!-- Add the portal bridge controller def -->
403         <replace file="${app.dest.webinf}/struts-config.xml">
404           <replacetoken><![CDATA[<!-- portlet controller def here -->]]></replacetoken>
405           <replacevalue><![CDATA[<controller pagePattern="$M$P" inputForward="true"
406                   processorClass="org.apache.portals.bridges.struts.PortletRequestProcessor"/>]]>
407           </replacevalue>
408         </replace>
409
410         <antcall target="add.jetspeed2" inheritRefs="true" />
411         <antcall target="add.uportal2" inheritRefs="true" />
412         <antcall target="add.liferay4" inheritRefs="true" />
413       </then>
414     </if>
415
416     <copy todir="${app.dest.lib}">
417       <fileset dir="${struts.dir}">
418         <include name="*.jar"/>
419       </fileset>
420     </copy>
421
422     <copy todir="${app.dest.lib}" file="${antlr.jar}"/>
423     <copy todir="${app.dest.lib}" file="${commons-beanutils.jar}"/>
424     <copy todir="${app.dest.lib}" file="${digester.jar}"/>
425     <copy todir="${app.dest.lib}" file="${commons-fileupload.jar}"/>
426     <copy todir="${app.dest.lib}" file="${commons-logging.jar}"/>
427     <copy todir="${app.dest.lib}" file="${commons-validator.jar}"/>
428     <copy todir="${app.dest.lib}" file="${jakarta-oro.jar}"/>
429   </target>
430
431   <!-- =================================================================
432        Jetspeed 2 modifications
433        ================================================================= -->
434
435   <target name="add.jetspeed2" if="org.bedework.build.for.jetspeed2" >
436     <copy todir="${app.dest.webinf}/tlds" >
437       <fileset dir="${org.bedework.default.lib}/${jetspeed2.jars.dir}/portals-bridges-struts">
438         <include name="*.tld"/>
439       </fileset>
440     </copy>
441   </target>
442
443   <!-- =================================================================
444        Uportal 2 modifications
445        ================================================================= -->
446
447   <target name="add.uportal2" if="org.bedework.build.for.uportal2" >
448     <copy todir="${app.dest.lib}" >
449       <fileset dir="${bin.home}">
450         <include name="bw-uportal*.jar"/>
451       </fileset>
452     </copy>
453
454     <!-- Add the portlet servlet mapping -->
455     <replace file="${app.temp.web.xml">
456       <replacetoken><![CDATA[<!-- portlet servlet mapping here -->]]></replacetoken>
457       <replacevalue><![CDATA[<servlet-mapping>
458     <servlet-name>@PORTLET-NAME@</servlet-name>
459     <url-pattern>/@PORTLET-NAME@/*</url-pattern>
460   </servlet-mapping>]]>
461       </replacevalue>
462     </replace>
463
464   </target>
465
466   <!-- =================================================================
467        Liferay 4 modifications
468        ================================================================= -->
469
470   <target name="add.liferay4" if="org.bedework.build.for.liferay4" >
471    <!-- Add liferay config files -->
472     <copy todir="${app.dest.webinf}" >
473       <fileset dir="${app.sou.dir}/war/WEB-INF" >
474         <include name="liferay*"/>
475       </fileset>
476       <filterset refid="property.filters" />
477     </copy>
478
479     <copy todir="${app.dest.lib}" >
480       <fileset dir="${bin.home}">
481         <include name="bw-liferay*.jar"/>
482       </fileset>
483       <fileset dir="${liferay4.lib}">
484         <include name="*.jar"/>
485       </fileset>
486     </copy>
487
488     <!-- Add the context params -->
489     <replace file="${app.temp.web.xml}">
490       <replacetoken><![CDATA[<!-- add context params here -->]]></replacetoken>
491       <replacevalue><![CDATA[<!-- add context params here -->
492
493   <context-param>
494     <param-name>company_id</param-name>
495     <param-value>@LIFERAY-COMPANY-ID@</param-value>
496   </context-param>]]>
497       </replacevalue>
498     </replace>
499
500     <!-- Add the portal listener -->
501     <replace file="${app.temp.web.xml}">
502       <replacetoken><![CDATA[<!-- add listeners here -->]]></replacetoken>
503       <replacevalue><![CDATA[<!-- add listeners here -->
504
505   <listener>
506     <listener-class>
507       @PORTAL-SERVLET-CONTEXT-LISTENER@
508     </listener-class>
509   </listener>]]>
510       </replacevalue>
511     </replace>
512
513     <!-- Add the portlet servlet definition -->
514     <replace file="${app.temp.web.xml}">
515       <replacetoken><![CDATA[<!-- add servlet definitions here -->]]></replacetoken>
516       <replacevalue><![CDATA[<!-- add servlet definitions here -->
517
518   <!-- Servlet definition for portlet use. -->
519   <servlet>
520     <servlet-name>@PORTLET-NAME@</servlet-name>
521     <display-name>@PORTLET-NAME@ Wrapper</display-name>
522     <servlet-class>@PORTLET-SERVLET-CLASS@</servlet-class>
523     <init-param>
524       <param-name>portlet-class</param-name>
525       <param-value>@PORTLET-CLASS@</param-value>
526     </init-param>
527     <init-param>
528       <param-name>portlet-guid</param-name>
529       <param-value>@CONTEXT-ROOT@.@PORTLET-NAME@</param-value>
530     </init-param>
531   </servlet>]]>
532       </replacevalue>
533     </replace>
534
535     <!-- Add the portlet servlet mapping -->
536     <replace file="${app.temp.web.xml}">
537       <replacetoken><![CDATA[<!-- add servlet mappings here -->]]></replacetoken>
538       <replacevalue><![CDATA[<!-- add servlet mappings here -->
539
540   <servlet-mapping>
541     <servlet-name>@PORTLET-NAME@</servlet-name>
542     <url-pattern>/@PORTLET-NAME@/*</url-pattern>
543   </servlet-mapping>]]>
544       </replacevalue>
545     </replace>
546   </target>
547
548   <!-- =================================================================
549        If this is a j2ee app the following gets executed.
550        We create an uodated jboss-web.xml file (for jboss) and a ear
551        ================================================================= -->
552
553   <target name="jboss-stuff" if="org.bedework.build.for.jboss">
554     <copy todir="${app.dest.webinf}"
555           file="${app.sou.dir}/war/WEB-INF/jboss-web.xml">
556       <filterset refid="property.filters" />
557     </copy>
558     <antcall target="jboss-virtual-host" inheritRefs="true" />
559   </target>
560
561   <target name="jboss-virtual-host" if="org.bedework.global.virtual.host">
562     <replace file="${app.dest.webinf}/jboss-web.xml">
563       <replacetoken><![CDATA[<!-- Virtual host -->]]></replacetoken>
564       <replacevalue><![CDATA[<virtual-host>@VIRTUAL-HOST@</virtual-host>
565       ]]>
566       </replacevalue>
567     </replace>
568     <replace file="${app.dest.webinf}/jboss-web.xml">
569       <replacefilter token="@VIRTUAL-HOST@" value="${org.bedework.global.virtual.host}"/>
570     </replace>
571   </target>
572
573   <target name="build.ear" if="cal.j2ee">
574     <ant antfile="${buildear}"
575          inheritRefs="true" target="build" />
576   </target>
577 </project>
Note: See TracBrowser for help on using the browser.