Cleaned up build.xml.
[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="../${app.name}"/>
61
62
63 <!-- No customization required after this line -->
64
65   <property environment="env"/>
66   <property name="dist.home"      value="${deploy.home}"/>
67   <property name="deploy.webinf"  value="${deploy.home}/WEB-INF"/>
68   <property name="deploy.classes" value="${deploy.webinf}/classes"/>
69   <property name="dist.src"       value="${app.name}.jar"/>
70   <property name="dist.war"       value="${app.name}.war"/>
71   <property name="javadoc.home"   value="${deploy.home}/javadoc"/>
72   <property name="tomcat.home"    value="${env.TOMCAT_HOME}"/>
73
74   <!-- If you want to use the very good jikes compiler, uncomment this 
75   <property name="build.compiler"   value="jikes"/> -->
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     <fileset dir="lib">
85       <include name="*.jar"/>
86     </fileset>
87     <pathelement path="${tomcat.home}/lib/tomcat.jar"/>
88         <fileset dir="${tomcat.home}/lib/common">
89                 <include name="*.jar" />
90         </fileset>
91   </path>
92
93
94
95 <!-- The "prepare" target is used to construct the deployment home
96      directory structure (if necessary), and to copy in static files
97      as required.  In the example below, Ant is instructed to create
98      the deployment directory, copy the contents of the "web/" source
99      hierarchy, and set up the WEB-INF subdirectory appropriately.
100 -->
101
102   <target name="prepare">
103     <mkdir  dir="${deploy.home}"/>
104     <copy todir="${deploy.home}">
105       <fileset dir="web"/>
106     </copy>
107     <mkdir  dir="${deploy.home}/templates"/>
108     <copy todir="${deploy.home}/templates">
109       <fileset dir="templates"/>
110     </copy>
111     <mkdir  dir="${deploy.home}/src"/>
112     <copy todir="${deploy.home}/src">
113       <fileset dir="source"/>
114     </copy>
115
116     <mkdir  dir="${deploy.home}/WEB-INF"/>
117     <copy  file="etc/web.xml"          tofile="${deploy.home}/WEB-INF/web.xml"/>
118     <mkdir  dir="${deploy.classes}"/>
119     <mkdir  dir="${deploy.home}/WEB-INF/lib"/>
120     <copy todir="${deploy.home}/WEB-INF/lib">
121       <fileset dir="lib">
122         <exclude name="ant.jar"/>
123         <exclude name="xerces.jar"/>
124       </fileset>
125     </copy>
126     <mkdir  dir="${javadoc.home}"/>
127     <mkdir  dir="${deploy.home}/log"/>
128
129   </target>
130
131
132
133 <!-- The "clean" target removes the deployment home directory structure,
134      so that the next time the "compile" target is requested, it will need
135      to compile everything from scratch.
136 -->
137
138
139   <target name="clean">
140     <delete dir="${deploy.classes}"/>
141         <mkdir dir="${deploy.classes}"/>
142   </target>
143
144
145
146 <!-- The "mrproper" target removes the entire deploy dir - including all
147         built pages and images.
148 -->
149
150   <target name="mrproper">
151     <delete dir="${deploy.home}"/>
152   </target>
153
154
155
156 <!-- The "compile" target is used to compile (or recompile) the Java classes
157      that make up this web application.  The recommended source code directory
158      structure makes this very easy because the <javac> task automatically
159      works its way down a source code hierarchy and compiles any class that
160      has not yet been compiled, or where the source file is newer than the
161      class file.
162
163      Feel free to adjust the compilation option parameters (debug,
164      optimize, and deprecation) to suit your requirements.  It is also
165      possible to base them on properties, so that you can adjust this
166      behavior at runtime.
167
168      The "compile" task depends on the "prepare" task, so the deployment
169      home directory structure will be created if needed the first time.
170 -->
171
172   <target name="compile" depends="prepare">
173         <antcall target="clean"/>
174     <javac srcdir="source" destdir="${deploy.classes}"
175            debug="on" optimize="off" deprecation="on">
176       <classpath refid="project.class.path"/>
177         </javac>
178     <copy   todir="${deploy.classes}">
179       <fileset dir="source" includes="**/*.properties"/>
180     </copy>
181     <copy   todir="${deploy.home}">
182       <fileset dir="source" includes="**/content-types.properties"/>
183       <fileset dir="source" includes="**/server.xml"/>
184     </copy>
185     <copy   todir="${deploy.classes}/bundles">
186       <fileset dir="bundles" includes="**/*.properties"/>
187     </copy>
188   </target>
189
190
191
192   <target name="perms">
193         <exec executable="./perms.sh"/>
194   </target>
195
196
197 <!-- The "javadoc" target is used to create the Javadoc API documentation
198      for the Java classes in this web application.  It is assumed that
199      this documentation is included in the deployed application, so the
200      example below generates the Javadoc HTML files in a subdirectory under
201      the deployment home directory.  Feel free to customize the options for
202      the JavaDoc task, after consulting the Ant documentation.
203 -->
204
205   <target name="javadoc" depends="prepare">
206     <javadoc packagenames="mir.*, mircoders.*"
207              sourcefiles="source/${app.name}.java,source/Open${app.name}.java"
208              sourcepath="source"
209              destdir="${javadoc.home}">
210           <classpath refid="project.class.path"/>
211         </javadoc>
212   </target>
213
214
215 <!-- The "all" target rebuilds everything by executing the "clean"
216      target first, which forces the "compile" target to compile all
217      source code instead of just the files that have been changed.
218 -->
219
220   <target name="all" depends="clean,prepare,compile,javadoc"/>
221
222
223 <!-- The "dist" target builds the distribution Web ARchive (WAR) file
224      for this application, suitable for distribution to sites that wish
225      to install your application.  It also creates a JAR file containing
226      the source code for this application, if you wish to distribute
227      that separately.
228 -->
229   <target name="dist" depends="prepare,compile">
230     <jar jarfile="${dist.home}/mirbase.jar"
231          includes="mir/**"
232          basedir="${deploy.classes}"/>
233     <jar jarfile="${dist.home}/${dist.src}"
234          basedir="./source"/>
235     <jar jarfile="${dist.home}/${dist.war}"
236          basedir="${deploy.home}"
237          excludes="${dist.war}"/>
238   </target>
239
240 </project>