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