1608988d0c5b232db9bf3b19f09290bfe458dc42
[mir.git] / build.xml-new
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      app.name          Base name of this application, used to
13                        construct filenames and directories.
14
15      deploy.home       The name of the directory into which the
16                        deployment hierarchy will be created.
17                        Normally, this will be the name of a
18                        subdirectory under $TOMCAT_HOME/webapps.
19
20      dist.home         The name of the base directory in which
21                        distribution files are created.
22
23      dist.src          The name of the distribution JAR file
24                        containing the application source code,
25                        to be stored in the "dist.home" directory.
26                        This filename should end with ".jar".
27
28      dist.war          The name of the Web ARchive (WAR) file
29                        containing our deployable application.
30                        This filename should end with ".war".
31
32      javadoc.home      The name of the base directory in which
33                        the JavaDoc documentation for this application
34                        is generated.
35
36      tomcat.home       The name of the base directory in which
37                        Tomcat has been installed.  This value is
38                        normally set automatically from the value
39                        of the TOMCAT_HOME environment variable.
40
41         java.home          The location of your Java SDK.
42
43         java.localhome     Where your local java classes and jar files 
44                        are located.
45
46         tomcat.home        The location of the tomcat root directory.
47
48 -->
49
50   <property name="app.name"       value="Mir"/>
51   <property name="deploy.home"    value="../${app.name}"/>
52   <property name="dist.home"      value="${deploy.home}"/>
53   <property name="dist.src"       value="${app.name}.jar"/>
54   <property name="dist.war"       value="${app.name}.war"/>
55   <property name="javadoc.home"   value="${deploy.home}/javadoc"/>
56
57   <property name="java.home"      value="/usr/lib/j2sdk1.3/"/>
58   <property name="java.localhome" value="/usr/share/java/"/>
59   <property name="tomcat.home"    value="/usr/share/tomcat/"/>
60
61
62   <!-- Construct the classpath -->
63   <path id="project.class.path">
64     <pathelement path="${deploy.home}"/>
65     <pathelement path="${deploy.home}/WEB-INF/classes"/>
66     <pathelement path="source"/>
67     <fileset dir="lib">
68       <include name="*.jar"/>
69     </fileset>
70     <fileset dir="${java.home}/lib">
71       <include name="tools.jar"/>
72       <include name="rt.jar"/>
73     </fileset>
74     <fileset dir="${java.localhome}">
75       <include name="*.jar"/>
76     </fileset>
77     <pathelement path="${tomcat.home}/lib/tomcat.jar"/>
78   </path>
79
80
81
82 <!-- The "prepare" target is used to construct the deployment home
83      directory structure (if necessary), and to copy in static files
84      as required.  In the example below, Ant is instructed to create
85      the deployment directory, copy the contents of the "web/" source
86      hierarchy, and set up the WEB-INF subdirectory appropriately.
87 -->
88
89   <target name="prepare">
90     <mkdir  dir="${deploy.home}"/>
91     <copy todir="${deploy.home}">
92       <fileset dir="web"/>
93     </copy>
94     <mkdir  dir="${deploy.home}/templates"/>
95     <copy todir="${deploy.home}/templates">
96       <fileset dir="templates"/>
97     </copy>
98     <mkdir  dir="${deploy.home}/src"/>
99     <copy todir="${deploy.home}/src">
100       <fileset dir="source"/>
101     </copy>
102
103     <mkdir  dir="${deploy.home}/WEB-INF"/>
104     <copy  file="etc/web.xml"          tofile="${deploy.home}/WEB-INF/web.xml"/>
105     <mkdir  dir="${deploy.home}/WEB-INF/classes"/>
106     <mkdir  dir="${deploy.home}/WEB-INF/lib"/>
107     <copy todir="${deploy.home}/WEB-INF/lib">
108       <fileset dir="lib">
109         <exclude name="ant.jar"/>
110         <exclude name="xerces.jar"/>
111       </fileset>
112     </copy>
113     <copy todir="${deploy.home}/WEB-INF/classes">
114       <fileset dir="bundles"/>
115     </copy>
116     <mkdir  dir="${javadoc.home}"/>
117     <mkdir  dir="${deploy.home}/log"/>
118
119   </target>
120
121
122 <!-- The "clean" target removes the deployment home directory structure,
123      so that the next time the "compile" target is requested, it will need
124      to compile everything from scratch.
125 -->
126
127
128   <target name="clean">
129     <delete dir="${deploy.home}"/>
130   </target>
131
132
133 <!-- The "compile" target is used to compile (or recompile) the Java classes
134      that make up this web application.  The recommended source code directory
135      structure makes this very easy because the <javac> task automatically
136      works its way down a source code hierarchy and compiles any class that
137      has not yet been compiled, or where the source file is newer than the
138      class file.
139
140      Feel free to adjust the compilation option parameters (debug,
141      optimize, and deprecation) to suit your requirements.  It is also
142      possible to base them on properties, so that you can adjust this
143      behavior at runtime.
144
145      The "compile" task depends on the "prepare" task, so the deployment
146      home directory structure will be created if needed the first time.
147 -->
148
149   <target name="compile" depends="prepare">
150     <javac srcdir="source" destdir="${deploy.home}/WEB-INF/classes"
151            debug="on" optimize="off" deprecation="on">
152       <classpath refid="project.class.path"/>
153         </javac>
154     <copy   todir="${deploy.home}/WEB-INF/classes">
155       <fileset dir="source" includes="**/*.properties"/>
156     </copy>
157     <copy   todir="${deploy.home}">
158       <fileset dir="source" includes="**/content-types.properties"/>
159     </copy>
160         <echo>
161                 Now you should call perms.sh(-dist) in order to set
162                 the permissions of your installed files to a meaningful
163                 value. 
164                 Have fun with Mir!
165         </echo>
166   </target>
167
168
169 <!-- The "javadoc" target is used to create the Javadoc API documentation
170      for the Java classes in this web application.  It is assumed that
171      this documentation is included in the deployed application, so the
172      example below generates the Javadoc HTML files in a subdirectory under
173      the deployment home directory.  Feel free to customize the options for
174      the JavaDoc task, after consulting the Ant documentation.
175 -->
176
177   <target name="javadoc" depends="prepare">
178     <javadoc packagenames="mir.*, mircoders.*"
179              sourcefiles="source/${app.name}.java,source/Open${app.name}.java"
180              sourcepath="source"
181              destdir="${javadoc.home}">
182           <classpath refid="project.class.path"/>
183         </javadoc>
184   </target>
185
186
187 <!-- The "all" target rebuilds everything by executing the "clean"
188      target first, which forces the "compile" target to compile all
189      source code instead of just the files that have been changed.
190 -->
191
192   <target name="all" depends="clean,prepare,compile,javadoc"/>
193
194
195 <!-- The "dist" target builds the distribution Web ARchive (WAR) file
196      for this application, suitable for distribution to sites that wish
197      to install your application.  It also creates a JAR file containing
198      the source code for this application, if you wish to distribute
199      that separately.
200 -->
201   <target name="dist" depends="prepare,compile">
202     <jar jarfile="mirbase.jar"
203          includes="mir/**"
204          basedir="../Mir/WEB-INF/classes"/>
205     <jar jarfile="${dist.src}"
206          basedir="./source"/>
207     <jar jarfile="${dist.war}"
208          basedir="${deploy.home}"/>
209   </target>
210
211 </project>