Default raget is :usage
[jalview.git] / build.xml
1 <?xml version="1.0"?>
2   <project name="jalviewX" default="usage" basedir=".">
3 <!-- we use jalopy to format our sources -->
4 <taskdef name="jalopy"
5          classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
6   <classpath>
7     <fileset dir="utils/jalopy/lib">
8       <include name="*.jar" />
9     </fileset>
10   </classpath>
11 </taskdef>
12
13    <target name="usage">
14      <echo message="~~~Jalview Ant build.xml Usage~~~~"/>
15      <echo message="Targets available:"/>
16      <echo message="usage - default target, displays this message"/>
17      <echo message="buildindices - generates JavaHelpSearch from the help files"/>
18      <echo message="build - compiles all necessary files for Application"/>
19      <echo message="makedist - compiles and places all necessary jar files into directory dist"/>
20      <echo message="makefulldist - signs all jar files and builds jnlp file for full distribution"/>
21      <echo message="compileApplet - compiles all necessary files for Applet"/>
22      <echo message="makeApplet - compiles, then packages and obfuscates the Applet"/>
23    </target>
24
25
26     <!-- utils is a class path to additional utilities needed for
27     building docs, jars and webstart stuff -->
28
29 <!--
30         Userdefined build property defaults
31
32         wsdl.server list (plus namespace mapping info ???)  - also want
33                 ... to make this a dynamically generatable property
34         WebStart Location
35         Build location - provide a temporary root for speed
36         jarsigner keystore and info
37         Jakarta and axis classpath ?
38         Default argument for starting Jalview (if it exists).
39
40 -->
41
42     <target name="init">
43       <path id="axis.classpath">
44 <!-->        <fileset dir="/usr/local/axis/lib">
45           <include name="**/*.jar" />
46         </fileset>
47         <fileset dir="/usr/local/jakarta-tomcat-5/webapps/axis/WEB-INF/lib">
48           <include name="**/*.jar"/>
49           <include name="*.jar"/>
50         </fileset> -->
51       </path>
52
53       <property name="JALVIEW_VERSION" value="ANNOTATION_TEST"/>
54       <property name="" value=""/>
55       <property name="libDir" value="lib"/>
56       <property name="resourceDir" value="resources"/>
57       <property name="helpDir" value="help"/>
58       <property name="docDir" value="doc"/>
59       <property name="sourceDir" value="src" />
60       <property name="outputDir" value="classes" />
61       <property name="packageDir" value="dist" />
62       <property name="outputJar" value="jalview.jar" />
63       <property name="wsdl.File" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred?wsdl" />
64       <property name="wsdl.Files" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/vamsas?wsdlFiles" />
65       <property name="wsdl.MsaWS" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS?wsdl" />
66       <property name="wsdl.MsaWS2" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS?wsdl" />
67       <property name="wsdl.MsaWS2" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS?wsdl" />
68         <property name="WSInterf" value="MsaWS" />
69       <property name="WebStartLocation" value="http://www.jalview.org/webstart"/>
70       <property name="wsdl.Namespace" value="vamsas" />
71       <property name="wsdl.ClientNS" value="ext.vamsas" />
72
73       <path id="build.classpath">
74         <fileset dir="utils">
75           <include name="*.jar"/>
76           <include name="**/*.jar"/>
77         </fileset>
78         <fileset dir="${libDir}">
79           <include name="*.jar"/>
80           <include name="**/*.jar"/>
81         </fileset>
82 <!--        <fileset dir="old_lib_signed">
83 <include name="lib_axis.jar"/>
84
85         </fileset>-->
86       </path>
87       <!-->    <uptodate property="help.uptodate"
88       targetfile="${helpDir}/helpIndex.xml">
89       <srcfiles
90                  dir="${helpDir}"
91                  includes="**/*.html" />
92                </uptodate>
93       -->
94     </target>
95
96
97     <taskdef classpath="utils/roxes-ant-tasks-1.2-2004-01-30.jar" resource="com/roxes/tools/ant/taskdefs.properties"/>
98     <target name="buildPropertiesFile" depends="init">
99       <tstamp prefix="build">
100         <format property="date" pattern="dd MMMM yyyy"/>
101       </tstamp>
102       <properties file="${outputDir}/.build_properties">
103         <header>
104           ---Jalview Build Details---
105         </header>
106         <property name="VERSION" value="${JALVIEW_VERSION}"/>
107         <property name="BUILD_DATE" value="${build.date}"/>
108       </properties>
109     </target>
110
111
112     <target name="clean" depends="init">
113       <!-- not efficient yet. -->
114       <delete dir="${outputDir}"/>
115     </target>
116
117     <target name="distclean" depends="init, clean">
118
119       <echo message="REMOVING ALL BACKUP/AUTOSAVES!"/>
120       <delete>
121         <fileset dir=".">
122           <include name="${outputJar}"/>
123           <include name="#*#"/>
124           <include name="#*.*#"/>
125           <include name="**/#*#"/>
126           <include name="**/#*.*#"/>
127           <include name="*~"/>
128           <include name="*.*~"/>
129           <include name="**/*~"/>
130           <include name="**/*.*~"/>
131         </fileset>
132       </delete>
133     </target>
134
135     <target name="prepare" depends="init">
136       <mkdir dir="${outputDir}"/>
137       <copy todir="${outputDir}">
138         <fileset dir=".">
139           <include name="${docDir}/**/*.*"/>
140           <include name="${helpDir}/**/*.*"/>
141           <include name="${libDir}/*.jar"/>
142         </fileset>
143         <fileset dir="${resourceDir}">
144           <include name="**/*.*"/>
145         </fileset>
146       </copy>
147     </target>
148
149     <target name="build" depends="prepare">
150       <!-- not efficient yet. -->
151       <javac source="1.4" target="1.4"
152         srcdir ="${sourceDir}"
153         destdir="${outputDir}"
154       classpathref="build.classpath">
155       <exclude name="jalview/*applet*"/>
156        <exclude name="com/stevesoft/**"/>
157       </javac>
158     </target>
159     <target name="buildindices" depends="init, prepare"
160     unless="help.uptodate">
161     <java
162       classname="com.sun.java.help.search.Indexer"
163       classpathref="build.classpath"
164       fork="true"
165       dir="${outputDir}/${helpDir}"
166       >
167       <arg line="html"/>
168     </java>
169     </target>
170
171     <target name="makefulldist" depends="makedist">
172  <!-- the default keystore details might need to be edited here -->
173       <signjar
174       storepass="alignmentisfun"
175       keypass="alignmentisfun"
176       keystore="keys/.keystore"
177       alias="jalview"
178       lazy="false"
179       verbose="false"
180       >
181
182       <fileset dir="${packageDir}">
183         <include name="*.jar"/>
184       </fileset>
185       </signjar>
186       <taskdef classpathref="build.classpath" resource="com/roxes/tools/ant/taskdefs.properties"/>
187
188       <!--    codebase="http://www.jalview.org/jalview/webstart" -->
189       <jnlp toFile="${packageDir}/jalview.jnlp" href="jalview.jnlp"
190       codebase="${WebStartLocation}">
191       <information>
192         <title>Jalview</title>
193         <vendor>The Barton Group</vendor>
194         <homepage href="http://www.jalview.org"/>
195         <description>Jalview Multiple Alignment Editor</description>
196         <description kind="short">Jalview</description>
197         <icon href="logo_big.gif"/>
198         <offline_allowed/>
199         <!--
200         <association mime-type="application-x/ext-file" extensions="fa"/>
201         <association mime-type="application-x/ext-file" extensions="fasta"/>
202         <association mime-type="application-x/ext-file" extensions="fastq"/>
203         <association mime-type="application-x/ext-file" extensions="blc"/>
204         <association mime-type="application-x/ext-file" extensions="msf"/>
205         <association mime-type="application-x/ext-file" extensions="pfam"/>
206         <association mime-type="application-x/ext-file" extensions="aln"/>
207         <association mime-type="application-x/ext-file" extensions="pir"/>
208         -->
209        </information>
210         <resources>
211           <j2se version="1.4+"/>
212           <fileset dir="${packageDir}">
213             <include name="jalview.jar"/>
214           </fileset>
215           <fileset dir="${packageDir}">
216             <include name="*.jar"/>
217             <exclude name="jalview.jar"/>
218           </fileset>
219           <property name="jalview.version" value="${JALVIEW_VERSION}"/>
220         </resources>
221         <application_desc main_class="jalview.bin.Jalview">
222           </application_desc>
223         <security>
224           <all_permissions/>
225         </security>
226       </jnlp>
227     </target>
228     <target name="runenv" depends="init">
229       <path id="run.classpath">
230         <pathelement location="${outputDir}"/>
231         <fileset dir="${outputDir}">
232           <include name="${libDir}/*.jar"/>
233         </fileset>
234       </path>
235       <pathconvert targetos="unix" refid="run.classpath" property="run.classpath"/>
236
237       <echo>java -classpath ${run.classpath} jalview.bin.Jalview
238       </echo>
239     </target>
240
241     <target name="buildextclients" depends="init">
242 <!-- Currently, this doesn't happen automatically.
243      1. Run WSDL2Java as below, which generates an ext.vamsas +
244      vamsas.<datapackages> fileset.
245      2. refactor ext.vamsas.SpecificserviceWS* to
246      ext.vamsas.ServiceclassWS* that implements the ServiceclassWSI interface.
247      3. Update the jalview.ws.*WServices classes to reflect the
248      interface type, and all locations of this wsdl type that Jalview
249      might be using.
250
251 -->
252       <path id="axisbuild">
253         <!--        <path refid="axis.classpath"/> -->
254         <path refid="build.classpath"/>
255       </path>
256       <taskdef resource="axis-tasks.properties" classpathref="axisbuild"/>
257       <move todir="./bak">
258         <fileset dir="${sourceDir}" id="client">
259           <include name="${wsdl.ClientNS}/*.*"/>
260         </fileset>
261       </move>
262
263       <axis-wsdl2java
264       output="${sourceDir}"
265       verbose="true"
266       url="${wsdl.MsaWS2}"
267       serverside="false"
268       deployscope="Request"
269       debug="false"
270       helpergen="true"
271       all="true"
272       >
273       <mappingSet>
274         <mapping
275         namespace="${wsdl.Namespace}"
276         package="${wsdl.ClientNS}"
277         />
278         <mapping namespace="http://dataTypes.vamsas"
279         package="${wsdl.ClientNS}"/>
280         </mappingSet>
281     </axis-wsdl2java>
282     </target>
283
284     <target name="makedist" depends="build, buildPropertiesFile, buildindices">
285       <!-- make the package jar -->
286       <mkdir dir="${packageDir}"/>
287
288       <jar destfile="${packageDir}/${outputJar}">
289         <manifest>
290              <attribute name="Main-Class" value="jalview.bin.Jalview"/>
291         </manifest>
292         <fileset dir="${outputDir}/">
293           <exclude name="cache*/**"/>
294           <exclude name="*.jar" />
295           <exclude name="*.jar.*" />
296           <exclude name="**/*.jar" />
297           <exclude name="**/*.jar.*" />
298         </fileset>
299       </jar>
300
301       <copy toDir="${packageDir}" flatten="true">
302         <fileset dir="${outputDir}">
303           <include name="*.jar"/>
304           <include name="**/*.jar"/>
305         </fileset>
306       </copy>
307   </target>
308
309
310
311   <target name="package" depends="init, build">
312
313   </target>
314   <!-- jalopy code reformatter -->
315   <target name="sourcescrub" depends="init,build">
316     <jalopy destdir="jsrc" classpathref="run.classpath"
317       convention="jalview-jalopy.xml">
318       <fileset dir="${sourceDir}">
319         <include name="*.java"/>
320         <include name="**/*.java"/>
321         <include name="**/**/*.java"/>
322       </fileset>
323       </jalopy>
324   </target>
325
326
327
328   <!-- Compile, package and obfuscate Jalview Applet -->
329   <target name="makeApplet" depends="obfuscate"/>
330
331   <target name="compileApplet" depends="init,clean">
332     <mkdir dir="${outputDir}"/>
333     <javac source="1.2" target="1.1" srcdir="${sourceDir}" destdir="${outputDir}"
334        includes="jalview/analysis/**,jalview/appletgui/**,jalview/datamodel/**jalview/jbappletgui/**,jalview/math/**,jalview/schemes/**"
335        excludes="ext/**,MCview/**,org/**,vamsas/**"/>
336   </target>
337
338   <target name="packageApplet" depends="compileApplet, buildPropertiesFile">
339   <copy file="${resourceDir}/images/idwidth.gif" toFile="${outputDir}/images/idwidth.gif"/>
340        <jar destfile="in.jar">
341         <manifest>
342             <attribute name="Main-Class" value="jalview.bin.JalviewLite"/>
343         </manifest>
344         <fileset dir="${outputDir}">
345           <include name="com/**"/>
346           <include name="MCview/**"/>
347           <include name="jalview/**"/>
348           <include name=".build_properties"/>
349           <include name="images/idwidth.gif"/>
350         </fileset>
351       </jar>
352   </target>
353
354   <target name="obfuscate" depends="packageApplet">
355     <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard.jar" />
356     <proguard>
357       -libraryjars "${java.home}/lib/rt.jar"
358       -injars      in.jar
359       -outjars     jalviewApplet.jar
360       -keep public class jalview.bin.JalviewLite
361        { public * ; }
362     </proguard>
363     <delete file="in.jar"/>
364   </target>
365
366
367 </project>