honour user CLASSPATH environment variable
[mir.git] / build.xml
1 <project name="Mir" default="deploy" basedir=".">
2   <!--
3     - Build script for the Mir project
4     -
5     - usefull tasks are:
6     -   * compile
7     -        Creates the jars needed for a mir deployment
8     -   * deploy
9     -        Sets up a deployment directory
10     -   * binary-distribution
11     -        Sets up a distributable version of mir in the
12     -        form of a war file
13     -   * source-distribution
14     -        Sets up a distributable version of mir as a
15     -        gzipped tar version of the source tree
16     -   * full-distribution
17     -        Sets up a distributable version of mir in the
18     -        form of a gzipped tar file with the sources
19     -   * javadoc
20     -        Generates the project's javadoc
21     -->
22
23   <property name="version"        value="1.1.0rc0"/>
24
25   <property name="app.name"       value="mir"/>
26
27   <!-- -->
28   <property name="deploy.home"    value="./bin/${app.name}"/>
29
30   <!-- The distribution will be built here: -->
31   <property name="distribution.home"      value="./dist"/>
32
33
34
35   <!-- The temporary files made during the build process
36        will be created here: -->
37   <property name="build"     value="./build"/>
38   <property name="build.classes"  value="./${build}/classes"/>
39   <property name="build.jars"  value="./${build}/jars"/>
40   <property name="build.javadoc"   value="${build}/javadoc"/>
41
42   <!-- retrieve environment variables -->
43   <property environment="env"/>
44
45   <property name="tomcat.home"    value="${env.TOMCAT_HOME}"/>
46   <property name="user.classpath" value="${env.CLASSPATH}"/>
47
48 <!--
49   <property name="compile.optimize" value="off" />
50   <property name="compile.debug" value="on" />
51   -->
52
53   <target name="deploy" depends="compile,generate-deployment-tree" 
54       description="Sets up a deployment directory">
55   </target>
56
57   <target name="debug" depends="compile-debug,generate-deployment-tree"
58       description="Sets up a deployment directory with debug enabled">
59   </target>
60
61   <target name="generate-deployment-tree">
62     <property name="destination" value="${deploy.home}"/>
63     <mkdir  dir="${destination}"/>
64     <mkdir  dir="${destination}/WEB-INF"/>
65     <delete dir="${destination}/WEB-INF/lib"/>
66     <mkdir  dir="${destination}/WEB-INF/lib"/>
67     <mkdir  dir="${destination}/WEB-INF/log"/>
68
69     <copy todir="${destination}">
70       <fileset dir="web"/>
71     </copy>
72
73     <copy todir="${destination}/WEB-INF/etc">
74       <fileset dir="etc" excludes="extrasource,extralib"/>
75     </copy>
76
77     <copy todir="${destination}/WEB-INF">
78       <fileset dir="meta"/>
79     </copy>
80
81     <copy todir="${destination}/WEB-INF/templates">
82       <fileset dir="templates"/>
83     </copy>
84
85     <copy todir="${destination}/WEB-INF/bundles">
86       <fileset dir="bundles"/>
87     </copy>
88
89     <copy todir="${destination}/WEB-INF" file="source/default.properties" />
90
91     <copy todir="${destination}/WEB-INF/lib">
92       <fileset dir="lib" />
93       <fileset dir="etc/extralib" />
94       <fileset dir="${build.jars}" />
95     </copy>
96   </target>
97
98   <target name="clean">
99     <delete dir="${build}"/>
100   </target>
101
102   <!-- Construct the classpath -->
103   <path id="project.classpath">
104         
105         <!-- for libs installed by user or OS distribuitor -->
106         <fileset dir="${user.classpath}">
107           <include name="*.jar" />
108     </fileset>
109
110         <fileset dir="lib">
111       <include name="*.jar"/>
112     </fileset>
113     <fileset dir="etc/extralib">
114       <include name="*.jar"/>
115     </fileset>
116
117     <pathelement path="${tomcat.home}/lib/tomcat.jar"/>
118
119     <!-- for libs shared between tomcat and webapps (tomcat 3.3.x) -->
120     <fileset dir="${tomcat.home}">
121                   <include name="lib/common/*.jar" />
122           </fileset>
123     <!-- for libs shared between webapps (tomcat 3.3.x) -->
124           <fileset dir="${tomcat.home}">
125                   <include name="lib/apps/*.jar" />
126           </fileset>
127     <!-- for libs shared between tomcat and webapps (tomcat 4.x.x) -->
128           <fileset dir="${tomcat.home}">
129                   <include name="common/lib/*.jar" />
130           </fileset>
131     <!-- for libs shared between webapps (tomcat 4.0.x) -->
132           <fileset dir="${tomcat.home}">
133                   <include name="lib/*.jar" />
134           </fileset>
135     <!-- for libs shared between webapps (tomcat 4.1.x) -->
136           <fileset dir="${tomcat.home}">
137                   <include name="shared/lib/*.jar" />
138           </fileset>
139
140           <fileset dir="${tomcat.home}">
141                   <include name="common/endorsed/*.jar" />
142           </fileset>
143   </path>
144
145
146   <target name="prepare-compilation">
147     <mkdir  dir="${build.classes}"/>
148     <mkdir  dir="${build.jars}"/>
149     <uptodate property="up.to.date" targetfile="${build.jars}/mir.jar">
150       <srcfiles dir="source" includes="**/*.java"/>
151       <srcfiles dir="lib" includes="*.jar"/>
152       <srcfiles dir="etc/extrasource" includes="**/*"/>
153       <srcfiles dir="etc/extralib" includes="*"/>
154     </uptodate>
155   </target>
156
157   <!-- compile target: compiles all files into the build/classes dir -->
158   <target name="compile" depends="prepare-compilation" unless="up.to.date"
159           description="Creates the jars needed for a mir deployment">
160           
161     <javac destdir="${build.classes}" debug="true" deprecation="off" source="1.3">
162       <src path="source"/>
163       <src path="etc/extrasource"/>
164       <classpath refid="project.classpath"/>
165     </javac>
166
167     <delete file="${build.jars}/mir.jar"/>
168
169     <jar
170        jarfile="${build.jars}/mir.jar">
171       <fileset dir="${build.classes}" includes="**/*.class" />
172       <manifest>
173         <attribute name="Built-By" value="${user.name}"/>
174       </manifest>
175     </jar>
176   </target>
177
178   <!-- compile a debuggable version -->
179   <target name="compile-debug" depends="prepare-compilation">
180     <javac destdir="${build.classes}"
181            debug="on" optimize="off" deprecation="on">
182       <src path="source"/>
183       <src path="etc/extrasource"/>
184       <classpath refid="project.classpath"/>
185     </javac>
186   </target>
187
188
189   <!-- build the project's javadoc -->
190   <target name="javadoc" depends="prepare-javadoc">
191     <javadoc
192         destdir="${build.javadoc}"
193         author="true"
194         version="true"
195         use="true"
196         packagenames="mir.*,mircoders.*"
197         sourcepath="source"
198         sourcefiles="source/Mir.java,source/OpenMir.java"
199         windowtitle="Mir">
200
201       <classpath refid="project.classpath"/>
202       <link href="http://java.sun.com/j2se/1.3/docs/api"/>
203     </javadoc>
204   </target>
205
206   <target name="prepare-javadoc">
207     <mkdir  dir="${build.javadoc}"/>
208   </target>
209
210   <target name="prepare-distribution">
211     <mkdir  dir="${distribution.home}"/>
212     <delete dir="${build}/dist"/>
213     <mkdir  dir="${build}/dist"/>
214   </target>
215
216   <target name="distribution" depends="prepare-distribution">
217     <antcall target="generate-deployment-tree">
218       <param name="destination" value="${build}/dist"/>
219     </antcall>
220
221     <tar tarfile="${distribution.home}/mir-${version}.tar.gz" compression="gzip">
222       <tarfileset dir="${build}/dist" includes="**/*" />
223     </tar>
224   </target>
225
226   <target name="prepare-source-distribution">
227     <mkdir  dir="${distribution.home}"/>
228   </target>
229
230   <target name="source-distribution" depends="prepare-source-distribution">
231     <!--<zip zipfile="${distribution.home}/mir-source-${version}.zip" >
232       <fileset dir="."
233         includes="bundles/**/*,source/**/*,etc/**/*,meta/**/*,web/**/*,templates/**/*,dbscripts/**/*,lib/**/*,doc/**/*,build.xml" />
234     </zip>-->
235     <tar tarfile="${distribution.home}/mir-source-${version}.tar.gz" compression="gzip">
236       <tarfileset dir="."
237         includes="bundles/**/*,source/**/*,etc/**/*,meta/**/*,web/**/*,templates/**/*,dbscripts/**/*,lib/**/*,doc/**/*,build.xml" />
238     </tar>
239
240   </target>
241   
242 <!--  
243   
244   <target name="documentation-pdf" description="generates documentation into html form">
245       <xslt in="${temp}/docs/pdf/${document}.xml"
246             out="${temp}/docs/pdf/${document}.fo"
247             style=""/>
248
249       <java classname="org.apache.fop.apps.Fop" fork="yes">
250           <classpath>
251               <fileset dir="lib">
252                   <include name="*.jar"/>
253               </fileset>
254           </classpath>
255
256           <arg value="-fo"/>
257           <arg file="${temp}/docs/pdf/${document}.fo"/>
258           <arg file="${build}/pdfdocs/${document}.pdf"/>
259       </java>
260   </target>
261 -->  
262   <target name="prepare-html">
263     <mkdir dir="${build}/xslt"/>
264  
265     <unzip dest="${build}/xslt" src="doc/lib/docbook-xsl-1.70.1.zip"/>
266  
267     <copy todir="${build}/xslt">
268       <fileset dir="doc/style">
269         <include name="*"/>
270       </fileset>
271     </copy>
272   </target>
273   
274   <target name="documentation-html" description="generates documentation into html form" depends="prepare-html">
275     <mkdir dir="${build}/htmldocs"/>
276
277     <xslt basedir="doc/installation" includes="*.xml"
278           destdir="${build}/htmldocs"
279           style="${build}/xslt/html.xsl"/>
280   </target>
281
282   <target name="full-distribution" depends="prepare-distribution,deploy,source-distribution">
283         <copy todir="${destination}/WEB-INF">
284               <fileset file="${distribution.home}/mir-source-${version}.tar.gz"/>
285             </copy>
286     <tar tarfile="${distribution.home}/mir-${version}.tar.gz" compression="gzip">
287       <tarfileset dir="bin" includes="**/*" />
288     </tar>
289   </target>
290
291 </project>