rebuilding head
[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     -        zipped version of the source tree
16     -   * javadoc
17     -        Generates the project's javadoc
18     -->
19
20   <property name="version"        value="1.1.0rc0"/>
21
22   <property name="app.name"       value="mir"/>
23
24   <!-- -->
25   <property name="deploy.home"    value="./bin/${app.name}"/>
26
27   <!-- The distribution will be built here: -->
28   <property name="distribution.home"      value="./dist"/>
29
30
31
32   <!-- The temporary files made during the build process
33        will be created here: -->
34   <property name="build.home"     value="./build"/>
35   <property name="build.classes"  value="./${build.home}/classes"/>
36   <property name="build.jars"  value="./${build.home}/jars"/>
37   <property name="build.javadoc"   value="${build.home}/javadoc"/>
38
39   <!-- retrieve environment variables -->
40   <property environment="env"/>
41 <!--
42   <property name="deploy.webinf"  value="${deploy.home}/WEB-INF"/>
43   <property name="deploy.classes" value="${deploy.webinf}/classes"/>
44
45   <property name="dist.src"       value="${app.name}.jar"/>
46   <property name="dist.war"       value="${app.name}.war"/>
47   -->
48   <property name="tomcat.home"    value="${env.TOMCAT_HOME}"/>
49
50 <!--
51   <property name="compile.optimize" value="off" />
52   <property name="compile.debug" value="on" />
53   -->
54
55   <target name="deploy" depends="compile,generate-deployment-tree" 
56       description="Sets up a deployment directory">
57   </target>
58
59   <target name="debug" depends="compile-debug,generate-deployment-tree"
60       description="Sets up a deployment directory with debug enabled">
61
62   </target>
63
64   <target name="generate-deployment-tree">
65     <property name="destination" value="${deploy.home}"/>
66     <mkdir  dir="${destination}"/>
67     <mkdir  dir="${destination}/WEB-INF"/>
68     <delete dir="${destination}/WEB-INF/lib"/>
69     <mkdir  dir="${destination}/WEB-INF/lib"/>
70     <mkdir  dir="${destination}/WEB-INF/log"/>
71
72     <copy todir="${destination}">
73       <fileset dir="web"/>
74     </copy>
75
76     <copy todir="${destination}/WEB-INF/etc">
77       <fileset dir="etc" excludes="extrasource,extralib"/>
78     </copy>
79
80     <copy todir="${destination}/WEB-INF">
81       <fileset dir="meta"/>
82     </copy>
83
84     <copy todir="${destination}/WEB-INF/templates">
85       <fileset dir="templates"/>
86     </copy>
87
88     <copy todir="${destination}/WEB-INF/bundles">
89       <fileset dir="bundles"/>
90     </copy>
91
92     <copy todir="${destination}/WEB-INF" file="source/default.properties" />
93
94     <copy todir="${destination}/WEB-INF/lib">
95       <fileset dir="lib" />
96       <fileset dir="etc/extralib" />
97       <fileset dir="${build.jars}" />
98     </copy>
99   </target>
100
101   <target name="clean">
102     <delete dir="${build.home}"/>
103   </target>
104
105   <!-- Construct the classpath -->
106   <path id="project.classpath">
107     <fileset dir="lib">
108       <include name="*.jar"/>
109     </fileset>
110     <fileset dir="etc/extralib">
111       <include name="*.jar"/>
112     </fileset>
113
114     <pathelement path="${tomcat.home}/lib/tomcat.jar"/>
115
116     <!-- for libs shared between tomcat and webapps (tomcat 3.3.x) -->
117     <fileset dir="${tomcat.home}">
118                   <include name="lib/common/*.jar" />
119           </fileset>
120     <!-- for libs shared between webapps (tomcat 3.3.x) -->
121           <fileset dir="${tomcat.home}">
122                   <include name="lib/apps/*.jar" />
123           </fileset>
124     <!-- for libs shared between tomcat and webapps (tomcat 4.x.x) -->
125           <fileset dir="${tomcat.home}">
126                   <include name="common/lib/*.jar" />
127           </fileset>
128     <!-- for libs shared between webapps (tomcat 4.0.x) -->
129           <fileset dir="${tomcat.home}">
130                   <include name="lib/*.jar" />
131           </fileset>
132     <!-- for libs shared between webapps (tomcat 4.1.x) -->
133           <fileset dir="${tomcat.home}">
134                   <include name="shared/lib/*.jar" />
135           </fileset>
136
137           <fileset dir="${tomcat.home}">
138                   <include name="common/endorsed/*.jar" />
139           </fileset>
140   </path>
141
142
143   <target name="prepare-compilation">
144     <mkdir  dir="${build.classes}"/>
145     <mkdir  dir="${build.jars}"/>
146     <uptodate property="up.to.date" targetfile="${build.jars}/mir.jar">
147       <srcfiles dir="source" includes="**/*.java"/>
148       <srcfiles dir="lib" includes="*.jar"/>
149       <srcfiles dir="etc/extrasource" includes="**/*"/>
150       <srcfiles dir="etc/extralib" includes="*"/>
151     </uptodate>
152   </target>
153
154   <!-- compile target: compiles all files into the build/classes dir -->
155   <target name="compile" depends="prepare-compilation" unless="up.to.date"
156           description="Creates the jars needed for a mir deployment">
157           
158     <javac destdir="${build.classes}" deprecation="on">
159       <src path="source"/>
160       <src path="etc/extrasource"/>
161       <classpath refid="project.classpath"/>
162     </javac>
163
164     <jar
165        jarfile="${build.jars}/mir.jar">
166       <fileset dir="${build.classes}" includes="**/*.class" />
167       <manifest>
168         <attribute name="Built-By" value="${user.name}"/>
169       </manifest>
170     </jar>
171   </target>
172
173   <!-- compile a debuggable version -->
174   <target name="compile-debug" depends="prepare-compilation">
175     <javac destdir="${build.classes}"
176            debug="on" optimize="off" deprecation="on">
177       <src path="source"/>
178       <src path="etc/extrasource"/>
179       <classpath refid="project.classpath"/>
180     </javac>
181   </target>
182
183
184   <!-- build the project's javadoc -->
185   <target name="javadoc" depends="prepare-javadoc">
186     <javadoc
187         destdir="${build.javadoc}"
188         author="true"
189         version="true"
190         use="true"
191         packagenames="mir.*,mircoders.*"
192         sourcepath="source"
193         sourcefiles="source/Mir.java,source/OpenMir.java"
194         windowtitle="Mir">
195
196       <classpath refid="project.classpath"/>
197       <link href="http://java.sun.com/j2se/1.3/docs/api"/>
198     </javadoc>
199   </target>
200
201   <target name="prepare-javadoc">
202     <mkdir  dir="${build.javadoc}"/>
203   </target>
204
205   <target name="prepare-binary-distribution">
206     <mkdir  dir="${distribution.home}"/>
207     <delete dir="${build.home}/binarydist"/>
208     <mkdir  dir="${build.home}/binarydist"/>
209   </target>
210
211   <target name="binary-distribution" depends="prepare-binary-distribution">
212     <antcall target="generate-deployment-tree">
213       <param name="destination" value="${build.home}/binarydist"/>
214     </antcall>
215
216     <zip zipfile="${distribution.home}/binary.zip" >
217       <fileset dir="${build.home}/binarydist" includes="**/*" />
218     </zip>
219   </target>
220
221   <target name="prepare-source-distribution">
222     <mkdir  dir="${distribution.home}"/>
223   </target>
224
225   <target name="source-distribution" depends="prepare-source-distribution">
226     <zip zipfile="${distribution.home}/source.zip" >
227       <fileset dir="."
228         includes="bundles/**/*,source/**/*,etc/**/*,meta/**/*,web/**/*,templates/**/*,dbscripts/**/*,lib/**/*,doc/**/*,build.xml" />
229     </zip>
230
231   </target>
232
233 </project>