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

Revision 1764 (checked in by douglm, 5 years ago)

Fix jboss build so that virtual hosts and context roots are set from the properties.

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     <!-- Add the contex root to the file. Note that newline is required -->
171     <echo file="${org.bedework.global.context.roots}" append="yes">
172 ${propval.app.war.name}.context=${propval.app.context.root}
173     </echo>
174
175     <!-- ===============================================================
176          Add hibernate jars and property files from calendar api.
177          =============================================================== -->
178
179     <copy todir="${app.dest.classes}">
180       <fileset dir="${org.bedework.project.calendarapi}/calCore/resources/properties" />
181       <filterset refid="property.filters" />
182     </copy>
183
184     <copy todir="${app.dest.classes}">
185       <fileset dir="${org.bedework.project.calendarapi}/calCore/resources/hbms" />
186       <filterset refid="property.filters" />
187     </copy>
188
189     <copy todir="${app.dest.lib}">
190       <fileset dir="${hibernate.jars.dir}">
191         <include name="*.jar"/>
192       </fileset>
193     </copy>
194
195     <antcall target="jboss-stuff" inheritRefs="true" />
196     <antcall target="bexchange-stuff" inheritRefs="true" />
197     <antcall target="domino-stuff" inheritRefs="true" />
198     <antcall target="google-stuff" inheritRefs="true" />
199
200     <!-- ===============================================================
201          Any jar files required
202          =============================================================== -->
203
204     <copy todir="${app.dest.lib}" overwrite="yes">
205       <fileset dir="${bin.home}">
206         <!-- jars from sub-projects needed by all -->
207         <include name="rpiaccess*.jar"/>
208         <include name="rpiutil*.jar"/>
209         <include name="bw-davio*.jar"/>
210
211         <!-- Calendar api jars -->
212         <include name="bw-apiutil*.jar"/>
213         <include name="bw-calcore*.jar"/>
214         <include name="bw-calcorei*.jar"/>
215         <include name="bw-calenv*.jar"/>
216         <include name="bw-calfacade*.jar"/>
217         <include name="bw-calsvc*.jar"/>
218         <include name="bw-calsvci*.jar"/>
219         <include name="bw-client*.jar"/>
220         <include name="bw-icalendar*.jar"/>
221         <include name="bw-locale*.jar"/>
222         <include name="bw-logging*.jar"/>
223         <include name="bw-mail*.jar"/>
224
225         <!-- Common jars for web apps -->
226         <include name="bw-appcommon*.jar"/>
227       </fileset>
228     </copy>
229
230      <!-- any extra bin files-->
231     <copy todir="${app.dest.lib}" >
232       <fileset refid="app.bin.files" />
233     </copy>
234
235     <!-- Some more standard libs -->
236     <if>
237       <not>
238         <isset property="org.bedework.build.for.jboss"/>
239       </not>
240       <then>
241         <copy todir="${app.dest.lib}" file="${log4j.jar}"/>
242       </then>
243     </if>
244     <copy todir="${app.dest.lib}" file="${lucene.core.jar}"/>
245     <copy todir="${app.dest.lib}" file="${lucene.misc.jar}"/>
246     <copy todir="${app.dest.lib}" file="${ical4j.jar}"/>
247     <copy todir="${app.dest.lib}" file="${commons-codec.jar}"/>
248     <copy todir="${app.dest.lib}" file="${commons-collections.jar}"/>
249     <copy todir="${app.dest.lib}" file="${commons-httpclient.jar}"/>
250     <copy todir="${app.dest.lib}" file="${commons-lang.jar}"/>
251     <copy todir="${app.dest.lib}" file="${commons-ssl.jar}"/>
252
253     <copy todir="${app.dest.lib}" overwrite="yes">
254       <fileset dir="${javamail.dir}">
255         <include name="*.jar"/>
256       </fileset>
257     </copy>
258
259     <!-- add the jdbcdriver if defined -->
260     <antcall target="add.jdbcdriver" inheritRefs="true" />
261
262     <!-- tomcat -->
263     <antcall target="add.tomcat" inheritRefs="true" />
264
265      <!-- any extra lib files-->
266     <copy todir="${app.dest.lib}" >
267       <fileset refid="app.lib.files" />
268       <!-- <fileset refid="app.temp.lib.files" /> -->
269     </copy>
270
271     <!-- build the war file -->
272     <mkdir dir="${dist.home}" />
273     <delete file="${app.war.file}" />
274
275     <war warfile="${app.war.file}"
276          webxml="${app.dest.web.xml}"
277          basedir="${app.dest.war}"
278          excludes="WEB-INF/web.xml" />
279   </target>
280
281   <target name="add.jdbcdriver" if="app.jdbcdriver.jar">
282     <copy todir="${app.dest.lib}" file="${app.jdbcdriver.jar}"/>
283   </target>
284
285   <target name="add.tomcat" if="org.bedework.global.deploy.on.tomcat">
286     <property name="propval.app.tomcat.context.xml"
287               location="${app.sou.dir}/war/META-INF/context.xml" />
288     <resolveFile name="app.tomcat.context.xml"
289                  file="${propval.app.tomcat.context.xml}"
290                  base="${app.sou.dir}"/>
291
292     <copy tofile="${app.dest.metainf}/context.xml"
293           file="${app.tomcat.context.xml}"
294           overwrite="yes" >
295       <filterset refid="property.filters" />
296     </copy>
297   </target>
298
299   <target name="copy.properties" if="org.bedework.properties.dir.exists">
300     <!-- ===============================================================
301          Any property files we need for configuration, other than the
302          standard struts file, should be in the "${app.sou.dir}/properties
303          directory. They will be copied into the appropriate place for the
304          war and transformed by the above filter.
305          =============================================================== -->
306     <copy todir="${app.dest.properties}" overwrite="yes" >
307       <fileset dir="${app.sou.dir}/properties"
308                includes="*.properties"/>
309       <filterset refid="property.filters" />
310     </copy>
311   </target>
312
313   <!--
314   <target name="copy.servlet.properties" if="org.bedework.servlet.properties.exists">
315     <copy tofile="${app.dest.classes}/servlet.properties" file="${app.sou.properties}">
316       <filterset refid="property.filters" />
317     </copy>
318   </target>
319   -->
320   <target name="copy.servlet.properties">
321     <copy todir="${app.dest.classes}">
322       <fileset dir="${app.sou.dir}/war/WEB-INF/classes"
323                includes="*"/>
324       <filterset refid="property.filters" />
325     </copy>
326   </target>
327
328   <target name="copy.war.docs" if="org.bedework.war.docs.exists">
329     <copy todir="${app.dest.docs}">
330       <fileset dir="${app.sou.dir}/war/docs" />
331     </copy>
332   </target>
333
334   <target name="bexchange-stuff" if="org.bedework.build.caldav.bexchange">
335     <copy tofile="${app.dest.properties}/timezones.xml"
336           file="${org.bedework.project.bedework}/docs/bwtimezones.xml" />
337   </target>
338
339   <target name="domino-stuff" if="org.bedework.build.caldav.domino">
340     <copy tofile="${app.dest.properties}/timezones.xml"
341           file="${org.bedework.project.bedework}/docs/bwtimezones.xml" />
342   </target>
343
344   <target name="google-stuff" if="org.bedework.build.caldav.google">
345     <copy todir="${app.dest.lib}">
346       <fileset dir="${google.dir}">
347         <include name="*.jar"/>
348       </fileset>
349     </copy>
350
351     <copy tofile="${app.dest.properties}/timezones.xml"
352           file="${org.bedework.project.bedework}/docs/bwtimezones.xml" />
353   </target>
354
355   <!-- =================================================================
356        If this is a struts app the following gets executed.
357        We create an updated struts-config.xml file and add some jars.
358        ================================================================= -->
359
360   <target name="struts-stuff" if="org.bedework.strutsapp">
361     <!-- Copy a dummy startup file into the war. -->
362     <copy todir="${app.dest.war}">
363       <fileset dir="${app.sou.dir}/war/" includes="setup.do" />
364     </copy>
365
366     <copy todir="${app.dest.webinf}"
367           file="${app.sou.dir}/war/WEB-INF/struts-config.xml"/>
368
369     <mkdir  dir="${app.dest.webinf}/tlds"/>
370     <copy todir="${app.dest.webinf}/tlds" >
371       <fileset dir="${struts.tlds.dir}">
372         <include name="*"/>
373       </fileset>
374     </copy>
375     <copy todir="${app.dest.webinf}/tlds" >
376       <fileset dir="${org.bedework.default.lib}/tlds">
377         <include name="*"/>
378       </fileset>
379     </copy>
380
381     <if>
382       <not>
383         <isset property="xalan.in.tomcat.common.endorsed" />
384       </not>
385       <then>
386         <copy todir="${app.dest.lib}" file="${xalan.jar}"/>
387       </then>
388     </if>
389
390     <if>
391       <isset property="org.bedework.global.portal.platform" />
392       <then>
393         <!-- Add common portlet files -->
394
395         <copy todir="${app.dest.lib}" >
396           <fileset dir="${portals-bridges.jars.dir}">
397             <include name="*.jar"/>
398           </fileset>
399         </copy>
400
401         <!-- Use generic bedework portlet tld -->
402         <copy todir="${app.dest.webinf}/tlds"
403               overwrite="yes"
404               failonerror="no" >
405           <fileset dir="${app.root.dir}/resources/portlet" >
406             <include name="*.tld"/>
407           </fileset>
408         </copy>
409
410         <copy todir="${app.dest.webinf}"
411               file="${org.bedework.deploy.type.dir}/portlet/struts-portlet-config.xml"
412               overwrite="yes"
413               failonerror="no" />
414
415         <copy todir="${app.dest.webinf}"
416               file="${org.bedework.deploy.type.dir}/portlet/portlet.xml"
417               overwrite="yes"
418               failonerror="no" >
419           <filterset refid="property.filters" />
420         </copy>
421
422         <!-- Add the portal bridge controller def -->
423         <replace file="${app.dest.webinf}/struts-config.xml">
424           <replacetoken><![CDATA[<!-- portlet controller def here -->]]></replacetoken>
425           <replacevalue><![CDATA[<controller pagePattern="$M$P" inputForward="true"
426                   processorClass="org.apache.portals.bridges.struts.PortletRequestProcessor"/>]]>
427           </replacevalue>
428         </replace>
429
430         <antcall target="add.jetspeed2" inheritRefs="true" />
431         <antcall target="add.uportal2" inheritRefs="true" />
432         <antcall target="add.liferay4" inheritRefs="true" />
433       </then>
434     </if>
435
436     <copy todir="${app.dest.lib}">
437       <fileset dir="${struts.dir}">
438         <include name="*.jar"/>
439       </fileset>
440     </copy>
441
442     <copy todir="${app.dest.lib}" file="${antlr.jar}"/>
443     <copy todir="${app.dest.lib}" file="${commons-beanutils.jar}"/>
444     <copy todir="${app.dest.lib}" file="${digester.jar}"/>
445     <copy todir="${app.dest.lib}" file="${commons-fileupload.jar}"/>
446     <copy todir="${app.dest.lib}" file="${commons-logging.jar}"/>
447     <copy todir="${app.dest.lib}" file="${commons-validator.jar}"/>
448     <copy todir="${app.dest.lib}" file="${jakarta-oro.jar}"/>
449   </target>
450
451   <!-- =================================================================
452        Jetspeed 2 modifications
453        ================================================================= -->
454
455   <target name="add.jetspeed2" if="org.bedework.build.for.jetspeed2" >
456     <copy todir="${app.dest.webinf}/tlds" >
457       <fileset dir="${org.bedework.default.lib}/${jetspeed2.jars.dir}/portals-bridges-struts">
458         <include name="*.tld"/>
459       </fileset>
460     </copy>
461   </target>
462
463   <!-- =================================================================
464        Uportal 2 modifications
465        ================================================================= -->
466
467   <target name="add.uportal2" if="org.bedework.build.for.uportal2" >
468     <copy todir="${app.dest.lib}" >
469       <fileset dir="${bin.home}">
470         <include name="bw-uportal*.jar"/>
471       </fileset>
472     </copy>
473
474     <!-- Add the portlet servlet mapping -->
475     <replace file="${app.temp.web.xml}">
476       <replacetoken><![CDATA[<!-- portlet servlet mapping here -->]]></replacetoken>
477       <replacevalue><![CDATA[<servlet-mapping>
478     <servlet-name>@PORTLET-NAME@</servlet-name>
479     <url-pattern>/@PORTLET-NAME@/*</url-pattern>
480   </servlet-mapping>]]>
481       </replacevalue>
482     </replace>
483
484   </target>
485
486   <!-- =================================================================
487        Liferay 4 modifications
488        ================================================================= -->
489
490   <target name="add.liferay4" if="org.bedework.build.for.liferay4" >
491    <!-- Add liferay config files -->
492     <copy todir="${app.dest.webinf}" >
493       <fileset dir="${app.sou.dir}/war/WEB-INF" >
494         <include name="liferay*"/>
495       </fileset>
496       <filterset refid="property.filters" />
497     </copy>
498
499     <copy todir="${app.dest.lib}" >
500       <fileset dir="${bin.home}">
501         <include name="bw-liferay*.jar"/>
502       </fileset>
503       <fileset dir="${liferay4.lib}">
504         <include name="*.jar"/>
505       </fileset>
506     </copy>
507
508     <!-- Add the context params -->
509     <replace file="${app.temp.web.xml}">
510       <replacetoken><![CDATA[<!-- add context params here -->]]></replacetoken>
511       <replacevalue><![CDATA[<!-- add context params here -->
512
513   <context-param>
514     <param-name>company_id</param-name>
515     <param-value>@LIFERAY-COMPANY-ID@</param-value>
516   </context-param>]]>
517       </replacevalue>
518     </replace>
519
520     <!-- Add the portal listener -->
521     <replace file="${app.temp.web.xml}">
522       <replacetoken><![CDATA[<!-- add listeners here -->]]></replacetoken>
523       <replacevalue><![CDATA[<!-- add listeners here -->
524
525   <listener>
526     <listener-class>
527       @PORTAL-SERVLET-CONTEXT-LISTENER@
528     </listener-class>
529   </listener>]]>
530       </replacevalue>
531     </replace>
532
533     <!-- Add the portlet servlet definition -->
534     <replace file="${app.temp.web.xml}">
535       <replacetoken><![CDATA[<!-- add servlet definitions here -->]]></replacetoken>
536       <replacevalue><![CDATA[<!-- add servlet definitions here -->
537
538   <!-- Servlet definition for portlet use. -->
539   <servlet>
540     <servlet-name>@PORTLET-NAME@</servlet-name>
541     <display-name>@PORTLET-NAME@ Wrapper</display-name>
542     <servlet-class>@PORTLET-SERVLET-CLASS@</servlet-class>
543     <init-param>
544       <param-name>portlet-class</param-name>
545       <param-value>@PORTLET-CLASS@</param-value>
546     </init-param>
547     <init-param>
548       <param-name>portlet-guid</param-name>
549       <param-value>@CONTEXT-ROOT@.@PORTLET-NAME@</param-value>
550     </init-param>
551   </servlet>]]>
552       </replacevalue>
553     </replace>
554
555     <!-- Add the portlet servlet mapping -->
556     <replace file="${app.temp.web.xml}">
557       <replacetoken><![CDATA[<!-- add servlet mappings here -->]]></replacetoken>
558       <replacevalue><![CDATA[<!-- add servlet mappings here -->
559
560   <servlet-mapping>
561     <servlet-name>@PORTLET-NAME@</servlet-name>
562     <url-pattern>/@PORTLET-NAME@/*</url-pattern>
563   </servlet-mapping>]]>
564       </replacevalue>
565     </replace>
566   </target>
567
568   <!-- =================================================================
569        If this is a j2ee app the following gets executed.
570        We create an uodated jboss-web.xml file (for jboss) and a ear
571        ================================================================= -->
572
573   <target name="jboss-stuff" if="org.bedework.build.for.jboss">
574     <copy todir="${app.dest.webinf}"
575           file="${app.sou.dir}/war/WEB-INF/jboss-web.xml">
576       <filterset refid="property.filters" />
577     </copy>
578
579     <if>
580       <isset property="propval.app.virtual.host" />
581       <then>
582         <replace file="${app.dest.webinf}/jboss-web.xml">
583           <replacetoken><![CDATA[<!-- Virtual host -->]]></replacetoken>
584           <replacevalue><![CDATA[<virtual-host>@VIRTUAL-HOST@</virtual-host>
585           ]]>
586           </replacevalue>
587         </replace>
588         <replace file="${app.dest.webinf}/jboss-web.xml">
589           <replacefilter token="@VIRTUAL-HOST@" value="${propval.app.virtual.host}"/>
590         </replace>
591       </then>
592     </if>
593   </target>
594
595   <target name="build.ear" if="cal.j2ee">
596     <ant antfile="${buildear}"
597          inheritRefs="true" target="build" />
598   </target>
599 </project>
Note: See TracBrowser for help on using the browser.