*** empty log message ***
[mir.git] / build.xml
1 <project name="Mir" default="compile" basedir=".">
2
3
4 <!-- What this file is all about
5
6      You can use this version of build.xml to use directly with ant
7      i.e. without the build.sh script. Simply call ant and let it all
8      happen.
9 -->
10
11 <!-- Property Definitions
12
13      Please not that only the first couple of properties have to be defined.
14      The rest, residing below the "no customization needed" line may be
15      customized if you know what you are doing. Else, leave the defaults
16      and use them to look up where ant places all the files.
17
18      app.name          Base name of this application, used to
19                        construct filenames and directories.
20
21      deploy.home       The name of the directory into which the
22                        deployment hierarchy will be created.
23                        Normally, this will be the name of a
24                        subdirectory under $TOMCAT_HOME/webapps.
25
26      deploy.classes    The name of the directory that will contain
27                        the class files.
28
29      dist.home         The name of the base directory in which
30                        distribution files are created.
31
32      dist.src          The name of the distribution JAR file
33                        containing the application source code,
34                        to be stored in the "dist.home" directory.
35                        This filename should end with ".jar".
36
37      dist.war          The name of the Web ARchive (WAR) file
38                        containing our deployable application.
39                        This filename should end with ".war".
40
41      javadoc.home      The name of the base directory in which
42                        the JavaDoc documentation for this application
43                        is generated.
44
45      tomcat.home       The name of the base directory in which
46                        Tomcat has been installed.  This value is
47                        normally set automatically from the value
48                        of the TOMCAT_HOME environment variable.
49
50         java.home          The location of your Java SDK.
51
52         java.localhome     Where your local java classes and jar files
53                        are located.
54
55         tomcat.home        The location of the tomcat root directory.
56
57 -->
58
59   <property name="app.name"       value="mir"/>
60   <property name="deploy.home"    value="./bin/${app.name}"/>
61
62   <!-- don't use unless your Jikes is >= v1.18 -->
63   <!-- <property name="build.compiler"   value="jikes"/>-->
64
65
66 <!-- No customization required after this line -->
67
68   <property environment="env"/>
69   <property name="dist.home"      value="${deploy.home}"/>
70   <property name="deploy.webinf"  value="${deploy.home}/WEB-INF"/>
71   <property name="deploy.classes" value="${deploy.webinf}/classes"/>
72   <property name="dist.src"       value="${app.name}.jar"/>
73   <property name="dist.war"       value="${app.name}.war"/>
74   <property name="javadoc.home"   value="${deploy.home}/javadoc"/>
75   <property name="tomcat.home"    value="${env.TOMCAT_HOME}"/>
76
77
78
79   <!-- Construct the classpath -->
80   <path id="project.class.path">
81     <pathelement path="${deploy.home}"/>
82     <pathelement path="${deploy.classes}"/>
83     <pathelement path="source"/>
84     <pathelement path="etc/extrasource"/>
85     <fileset dir="lib">
86       <include name="*.jar"/>
87     </fileset>
88     <fileset dir="lib/hibernate">
89       <include name="*.jar"/>
90     </fileset>
91     <pathelement path="${tomcat.home}/lib/tomcat.jar"/>
92   <!-- for libs shared between tomcat and webapps (tomcat 3.3.x) -->
93         <fileset dir="${tomcat.home}">
94                 <include name="lib/common/*.jar" />
95         </fileset>
96   <!-- for libs shared between webapps (tomcat 3.3.x) -->
97         <fileset dir="${tomcat.home}">
98                 <include name="lib/apps/*.jar" />
99         </fileset>
100   <!-- for libs shared between tomcat and webapps (tomcat 4.x.x) -->
101         <fileset dir="${tomcat.home}">
102                 <include name="common/lib/*.jar" />
103         </fileset>
104   <!-- for libs shared between webapps (tomcat 4.0.x) -->
105         <fileset dir="${tomcat.home}">
106                 <include name="lib/*.jar" />
107         </fileset>
108   <!-- for libs shared between webapps (tomcat 4.1.x) -->
109         <fileset dir="${tomcat.home}">
110                 <include name="shared/lib/*.jar" />
111         </fileset>
112         <fileset dir="${tomcat.home}">
113                 <include name="common/endorsed/*.jar" />
114         </fileset>
115   </path>
116
117
118
119 <!-- The "prepare" target is used to construct the deployment home
120      directory structure (if necessary), and to copy in static files
121      as required.  In the example below, Ant is instructed to create
122      the deployment directory, copy the contents of the "web/" source
123      hierarchy, and set up the WEB-INF subdirectory appropriately.
124 -->
125
126   <target name="prepare">
127     <mkdir  dir="${deploy.home}"/>
128     <mkdir  dir="${deploy.webinf}"/>
129     <mkdir  dir="${deploy.classes}"/>
130     <mkdir  dir="${deploy.webinf}/log"/>
131
132     <copy todir="${deploy.home}">
133       <fileset dir="web"/>
134     </copy>
135         
136     <copy todir="${deploy.webinf}/classes">
137         <fileset dir="source">
138                 <include name="*.xml"/>
139         </fileset>
140     </copy>
141
142     <copy todir="${deploy.webinf}/etc">
143       <fileset dir="etc" excludes="bundles/** hibernate.cfg.xml web.xml"/>
144     </copy>
145     <copy todir="${deploy.classes}/bundles">
146         <fileset dir="etc/bundles"/>
147     </copy>
148     <copy todir="${deploy.webinf}" file="etc/web.xml"/>
149
150     <copy todir="${deploy.webinf}/templates">
151       <fileset dir="templates"/>
152     </copy>
153     
154     <copy todir="${deploy.webinf}" file="source/default.properties" />
155     
156     <copy todir="${deploy.classes}/bundles">
157       <fileset dir="bundles"/>
158     </copy>
159     
160     <copy todir="${deploy.classes}" file="etc/hibernate.cfg.xml"/>
161     
162     <copy todir="${deploy.home}/WEB-INF/lib">
163       <fileset dir="lib">
164         <exclude name="ant.jar"/>
165         <exclude name="xerces.jar"/>
166       </fileset>
167       <fileset dir="lib/hibernate">
168       </fileset>
169     </copy>
170   </target>
171
172
173
174 <!-- The "clean" target removes the deployment home directory structure,
175      so that the next time the "compile" target is requested, it will need
176      to compile everything from scratch.
177 -->
178
179
180   <target name="clean">
181     <delete dir="${deploy.classes}"/>
182     <mkdir dir="${deploy.classes}"/>
183   </target>
184
185
186
187 <!-- The "mrproper" target removes the entire deploy dir - including all
188         built pages and images.
189 -->
190
191   <target name="mrproper">
192     <delete dir="${deploy.home}"/>
193   </target>
194
195   <!-- drop out if $TOMCAT_HOME is not set>-->
196   <target name="testtomcat" unless="tomcat.present">
197     <fail message="the $$TOMCAT_HOME environment variable is not set or is set to the wrong path. Please set it first. giving up!"/>
198   </target>
199
200 <!-- The "compile" target is used to compile (or recompile) the Java classes
201      that make up this web application.  The recommended source code directory
202      structure makes this very easy because the <javac> task automatically
203      works its way down a source code hierarchy and compiles any class that
204      has not yet been compiled, or where the source file is newer than the
205      class file.
206
207      Feel free to adjust the compilation option parameters (debug,
208      optimize, and deprecation) to suit your requirements.  It is also
209      possible to base them on properties, so that you can adjust this
210      behavior at runtime.
211
212      The "compile" task depends on the "prepare" task, so the deployment
213      home directory structure will be created if needed the first time.
214 -->
215
216   <target name="compile" depends="prepare">
217     <!-- check to see if $TOMCAT_HOME was set to something useful.. -->
218     <available file="${tomcat.home}/conf" property="tomcat.present"/>
219     <antcall target="testtomcat"/>
220
221     <!--<antcall target="clean"/>-->
222     <dependset>
223       <srcfileset
224         dir="source"
225         includes="**/*.java"/>
226 <!-- ML: now why can't this be added?
227       <srcfileset
228         dir="etc/extrasource"
229         includes="**/*.java"/> -->
230       <srcfileset
231         dir="lib"
232         includes="*.jar"/>
233       <targetfileset
234         dir="${deploy.classes}"
235         includes="**/*.class"/>
236     </dependset>
237     <javac destdir="${deploy.classes}"
238            debug="on" optimize="off" deprecation="on">
239       <src path="source"/>
240       <src path="etc/extrasource"/>
241       <classpath refid="project.class.path"/>
242     </javac>
243   </target>
244
245
246
247   <target name="perms">
248     <exec executable="./perms.sh"/>
249   </target>
250
251
252 <!-- The "javadoc" target is used to create the Javadoc API documentation
253      for the Java classes in this web application.  It is assumed that
254      this documentation is included in the deployed application, so the
255      example below generates the Javadoc HTML files in a subdirectory under
256      the deployment home directory.  Feel free to customize the options for
257      the JavaDoc task, after consulting the Ant documentation.
258 -->
259
260   <target name="javadoc" depends="prepare">
261     <javadoc packagenames="mir.*, mircoders.*"
262              sourcefiles="source/${app.name}.java,source/Open${app.name}.java"
263              sourcepath="source"
264              destdir="${javadoc.home}">
265           <classpath refid="project.class.path"/>
266         </javadoc>
267   </target>
268
269
270 <!-- The "all" target rebuilds everything by executing the "clean"
271      target first, which forces the "compile" target to compile all
272      source code instead of just the files that have been changed.
273 -->
274
275   <target name="all" depends="clean,prepare,compile,javadoc"/>
276
277
278 <!-- The "dist" target builds the distribution Web ARchive (WAR) file
279      for this application, suitable for distribution to sites that wish
280      to install your application.  It also creates a JAR file containing
281      the source code for this application, if you wish to distribute
282      that separately.
283 -->
284   <target name="dist" depends="prepare,compile">
285     <jar jarfile="${dist.home}/mirbase.jar"
286          includes="mir/**"
287          basedir="${deploy.classes}"/>
288     <jar jarfile="${dist.home}/${dist.src}"
289          basedir="./source"/>
290     <jar jarfile="${dist.home}/${dist.war}"
291          basedir="${deploy.home}"
292          excludes="${dist.war}"/>
293   </target>
294   
295   <target name="rundbtest" depends="compile">
296         <java classname="mir.core.test.Test">
297                 <classpath>
298                         <fileset dir="${deploy.webinf}/lib">
299                                 <include name="*.jar"/>
300                         </fileset>
301                         <path id="classes" path="${deploy.classes}"/>
302                 </classpath>
303                 <sysproperty key="org.xml.sax.driver" value="org.apache.xerces.parsers.SAXParser"/> 
304         </java>
305   </target>
306
307 </project>