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