Explicitly mark perms.sh-dist as a bash script.
[mir.git] / build.xml
1 <project name="Mir" default="deploy" basedir=".">
2   <!--
3     - Build script for the Mir project
4     -
5     - usefull tasks are:
6     -   * compile
7     -        Creates the jars needed for a mir deployment
8     -   * deploy
9     -        Sets up a deployment directory
10     -   * binary-distribution
11     -        Sets up a distributable version of mir in the
12     -        form of a war file
13     -   * source-distribution
14     -        Sets up a distributable version of mir as a
15     -        gzipped tar version of the source tree
16     -   * full-distribution
17     -        Sets up a distributable version of mir in the
18     -        form of a gzipped tar file with the sources
19     -   * javadoc
20     -        Generates the project's javadoc
21     -->
22
23   <property name="version"        value="1.1.0rc0"/>
24
25   <property name="app.name"       value="mir"/>
26
27   <!-- -->
28   <property name="deploy.home"    value="./bin/${app.name}"/>
29
30   <!-- The distribution will be built here: -->
31   <property name="distribution.home"      value="./dist"/>
32
33
34
35   <!-- The temporary files made during the build process
36        will be created here: -->
37   <property name="build"     value="./build"/>
38   <property name="build.classes"  value="./${build}/classes"/>
39   <property name="build.jars"  value="./${build}/jars"/>
40   <property name="build.javadoc"   value="${build}/javadoc"/>
41
42   <!-- retrieve environment variables -->
43   <property environment="env"/>
44
45   <property name="tomcat.home"    value="${env.TOMCAT_HOME}"/>
46
47 <!--
48   <property name="compile.optimize" value="off" />
49   <property name="compile.debug" value="on" />
50   -->
51
52   <target name="deploy" depends="compile,generate-deployment-tree" 
53       description="Sets up a deployment directory">
54   </target>
55
56   <target name="debug" depends="compile-debug,generate-deployment-tree"
57       description="Sets up a deployment directory with debug enabled">
58   </target>
59
60   <target name="generate-deployment-tree">
61     <property name="destination" value="${deploy.home}"/>
62     <mkdir  dir="${destination}"/>
63     <mkdir  dir="${destination}/WEB-INF"/>
64     <delete dir="${destination}/WEB-INF/lib"/>
65     <mkdir  dir="${destination}/WEB-INF/lib"/>
66     <mkdir  dir="${destination}/WEB-INF/log"/>
67
68     <copy todir="${destination}">
69       <fileset dir="web"/>
70     </copy>
71
72     <copy todir="${destination}/WEB-INF/etc">
73       <fileset dir="etc" excludes="extrasource,extralib"/>
74     </copy>
75
76     <copy todir="${destination}/WEB-INF">
77       <fileset dir="meta"/>
78     </copy>
79
80     <copy todir="${destination}/WEB-INF/templates">
81       <fileset dir="templates"/>
82     </copy>
83
84     <copy todir="${destination}/WEB-INF/bundles">
85       <fileset dir="bundles"/>
86     </copy>
87
88     <copy todir="${destination}/WEB-INF" file="source/default.properties" />
89
90     <copy todir="${destination}/WEB-INF/lib">
91       <fileset dir="lib" />
92       <fileset dir="etc/extralib" />
93       <fileset dir="${build.jars}" />
94     </copy>
95   </target>
96
97   <target name="clean">
98     <delete dir="${build}"/>
99   </target>
100
101   <!-- Construct the classpath -->
102   <path id="project.classpath">
103     <fileset dir="lib">
104       <include name="*.jar"/>
105     </fileset>
106     <fileset dir="etc/extralib">
107       <include name="*.jar"/>
108     </fileset>
109
110     <pathelement path="${tomcat.home}/lib/tomcat.jar"/>
111
112     <!-- for libs shared between tomcat and webapps (tomcat 3.3.x) -->
113     <fileset dir="${tomcat.home}">
114                   <include name="lib/common/*.jar" />
115           </fileset>
116     <!-- for libs shared between webapps (tomcat 3.3.x) -->
117           <fileset dir="${tomcat.home}">
118                   <include name="lib/apps/*.jar" />
119           </fileset>
120     <!-- for libs shared between tomcat and webapps (tomcat 4.x.x) -->
121           <fileset dir="${tomcat.home}">
122                   <include name="common/lib/*.jar" />
123           </fileset>
124     <!-- for libs shared between webapps (tomcat 4.0.x) -->
125           <fileset dir="${tomcat.home}">
126                   <include name="lib/*.jar" />
127           </fileset>
128     <!-- for libs shared between webapps (tomcat 4.1.x) -->
129           <fileset dir="${tomcat.home}">
130                   <include name="shared/lib/*.jar" />
131           </fileset>
132
133           <fileset dir="${tomcat.home}">
134                   <include name="common/endorsed/*.jar" />
135           </fileset>
136   </path>
137
138
139   <target name="prepare-compilation">
140     <mkdir  dir="${build.classes}"/>
141     <mkdir  dir="${build.jars}"/>
142     <uptodate property="up.to.date" targetfile="${build.jars}/mir.jar">
143       <srcfiles dir="source" includes="**/*.java"/>
144       <srcfiles dir="lib" includes="*.jar"/>
145       <srcfiles dir="etc/extrasource" includes="**/*"/>
146       <srcfiles dir="etc/extralib" includes="*"/>
147     </uptodate>
148   </target>
149
150   <!-- compile target: compiles all files into the build/classes dir -->
151   <target name="compile" depends="prepare-compilation" unless="up.to.date"
152           description="Creates the jars needed for a mir deployment">
153           
154     <javac destdir="${build.classes}" debug="true" deprecation="off" source="1.3">
155       <src path="source"/>
156       <src path="etc/extrasource"/>
157       <classpath refid="project.classpath"/>
158     </javac>
159
160     <delete file="${build.jars}/mir.jar"/>
161
162     <jar
163        jarfile="${build.jars}/mir.jar">
164       <fileset dir="${build.classes}" includes="**/*.class" />
165       <manifest>
166         <attribute name="Built-By" value="${user.name}"/>
167       </manifest>
168     </jar>
169   </target>
170
171   <!-- compile a debuggable version -->
172   <target name="compile-debug" depends="prepare-compilation">
173     <javac destdir="${build.classes}"
174            debug="on" optimize="off" deprecation="on">
175       <src path="source"/>
176       <src path="etc/extrasource"/>
177       <classpath refid="project.classpath"/>
178     </javac>
179   </target>
180
181
182   <!-- build the project's javadoc -->
183   <target name="javadoc" depends="prepare-javadoc">
184     <javadoc
185         destdir="${build.javadoc}"
186         author="true"
187         version="true"
188         use="true"
189         packagenames="mir.*,mircoders.*"
190         sourcepath="source"
191         sourcefiles="source/Mir.java,source/OpenMir.java"
192         windowtitle="Mir">
193
194       <classpath refid="project.classpath"/>
195       <link href="http://java.sun.com/j2se/1.3/docs/api"/>
196     </javadoc>
197   </target>
198
199   <target name="prepare-javadoc">
200     <mkdir  dir="${build.javadoc}"/>
201   </target>
202
203   <target name="prepare-distribution">
204     <mkdir  dir="${distribution.home}"/>
205     <delete dir="${build}/dist"/>
206     <mkdir  dir="${build}/dist"/>
207   </target>
208
209   <target name="distribution" depends="prepare-distribution">
210     <antcall target="generate-deployment-tree">
211       <param name="destination" value="${build}/dist"/>
212     </antcall>
213
214     <tar tarfile="${distribution.home}/mir-${version}.tar.gz" compression="gzip">
215       <tarfileset dir="${build}/dist" includes="**/*" />
216     </tar>
217   </target>
218
219   <target name="prepare-source-distribution">
220     <mkdir  dir="${distribution.home}"/>
221   </target>
222
223   <target name="source-distribution" depends="prepare-source-distribution">
224     <!--<zip zipfile="${distribution.home}/mir-source-${version}.zip" >
225       <fileset dir="."
226         includes="bundles/**/*,source/**/*,etc/**/*,meta/**/*,web/**/*,templates/**/*,dbscripts/**/*,lib/**/*,doc/**/*,build.xml" />
227     </zip>-->
228     <tar tarfile="${distribution.home}/mir-source-${version}.tar.gz" compression="gzip">
229       <tarfileset dir="."
230         includes="bundles/**/*,source/**/*,etc/**/*,meta/**/*,web/**/*,templates/**/*,dbscripts/**/*,lib/**/*,doc/**/*,build.xml" />
231     </tar>
232
233   </target>
234   
235 <!--  
236   
237   <target name="documentation-pdf" description="generates documentation into html form">
238       <xslt in="${temp}/docs/pdf/${document}.xml"
239             out="${temp}/docs/pdf/${document}.fo"
240             style=""/>
241
242       <java classname="org.apache.fop.apps.Fop" fork="yes">
243           <classpath>
244               <fileset dir="lib">
245                   <include name="*.jar"/>
246               </fileset>
247           </classpath>
248
249           <arg value="-fo"/>
250           <arg file="${temp}/docs/pdf/${document}.fo"/>
251           <arg file="${build}/pdfdocs/${document}.pdf"/>
252       </java>
253   </target>
254 -->  
255   <target name="prepare-html">
256     <mkdir dir="${build}/xslt"/>
257  
258     <unzip dest="${build}/xslt" src="doc/lib/docbook-xsl-1.70.1.zip"/>
259  
260     <copy todir="${build}/xslt">
261       <fileset dir="doc/style">
262         <include name="*"/>
263       </fileset>
264     </copy>
265   </target>
266   
267   <target name="documentation-html" description="generates documentation into html form" depends="prepare-html">
268     <mkdir dir="${build}/htmldocs"/>
269
270     <xslt basedir="doc/installation" includes="*.xml"
271           destdir="${build}/htmldocs"
272           style="${build}/xslt/html.xsl"/>
273   </target>
274
275   <target name="full-distribution" depends="prepare-distribution,deploy,source-distribution">
276         <copy todir="${destination}/WEB-INF">
277               <fileset file="${distribution.home}/mir-source-${version}.tar.gz"/>
278             </copy>
279     <tar tarfile="${distribution.home}/mir-${version}.tar.gz" compression="gzip">
280       <tarfileset dir="bin" includes="**/*" />
281     </tar>
282   </target>
283
284 </project>