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