root/trunk/build/buildwar.xml

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

More changes to the build process. Main build now pulls jars out of the archive and out of each projects bin directory.

Also remove some unused ant build code.

Not yet complete but close.

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