additional instructions and use of -jar for launching
[jalview.git] / build.xml
1 <?xml version="1.0"?>
2 <!--
3   Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)
4   Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5   
6   This program is free software; you can redistribute it and/or
7   modify it under the terms of the GNU General Public License
8   as published by the Free Software Foundation; either version 2
9   of the License, or (at your option) any later version.
10   
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15   
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
19 -->
20 <project name="jalviewX" default="usage" basedir=".">
21         <!-- we use jalopy to format our sources -->
22         <taskdef name="jalopy"
23          classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
24                 <classpath>
25                         <fileset dir="utils/jalopy/lib">
26                                 <include name="*.jar" />
27                         </fileset>
28                 </classpath>
29         </taskdef>
30
31         <target name="help" depends="usage"/>
32         <target name="usage">
33                 <echo message="~~~Jalview Ant build.xml Usage~~~~"/>
34                 <echo message="Targets include:"/>
35                 <echo message="usage - default target, displays this message"/>
36                 <echo message="buildindices - generates JavaHelpSearch from the help files"/>
37                 <echo message="build - compiles all necessary files for Application"/>
38                 <echo message="makedist - compiles and places all necessary jar files into directory dist"/>
39                 <echo message="makefulldist - signs all jar files and builds jnlp file for full distribution"/>
40                 <echo message="              this needs a keystore and key. See docs/building.html for more information."/>
41                 <echo message="compileApplet - compiles all necessary files for Applet"/>
42                 <echo message="makeApplet - compiles, then packages and obfuscates the Applet"/>
43                 <echo message="See docs/building.html and the comments in build file for other targets."/>
44             <echo message="note: compile and makeApplet require the property java118.home to be set to point to a java 1.1.8 jdk."/>
45             <echo message="Useful -D flags: -Ddonotobfuscate will prevent applet obfuscation"/>
46         </target>
47
48
49         <!-- utils is a class path to additional utilities needed for
50     building docs, jars and webstart stuff -->
51         <!--
52         Userdefined build property defaults
53
54         wsdl.server list (plus namespace mapping info ???)  - also want
55                 ... to make this a dynamically generatable property
56         WebStart Location
57         Build location - provide a temporary root for speed
58         jarsigner keystore and info
59         Jakarta and axis classpath ?
60         Default argument for starting Jalview (if it exists).
61
62 -->
63
64         <target name="init">
65                 <path id="axis.classpath">
66                         <!-->
67                         <fileset dir="/usr/local/axis/lib">
68                                 <include name="**/*.jar" />
69                         </fileset>
70                         <fileset dir="/usr/local/jakarta-tomcat-5/webapps/axis/WEB-INF/lib">
71                                 <include name="**/*.jar"/>
72                                 <include name="*.jar"/>
73                         </fileset> -->
74       </path>
75                 <!-- Jalview Version String displayed by application on startup and used to check for updates -->
76     <property name="JALVIEW_VERSION" value="DEVELOPMENT"/> <!-- 2.4 (VAMSAS)" -->
77                 <!-- Include debugging information in javac true or false -->
78                 <property name="javac.debug" value="true"/>
79                 
80                 <!-- JarSigner Key Store for Webstart Distribution -->
81                 <property name="jalview.keystore" value="./keys/.keystore"/>
82                 <!-- Keystore Password -->
83                 <property name="jalview.keystore.pass" value="alignmentisfun"/>
84                 <!-- Key Name -->
85                 <property name="jalview.key" value="jalview"/>
86                 <!-- Key Password -->
87                 <property name="jalview.key.pass" value="alignmentisfun"/>
88                                                 
89                 <!-- Don't change anything below here unless you know what you are doing! -->
90                 <!-- Url path for WebStart in JNLP file -->
91                 <property name="WebStartLocation" value="http://www.jalview.org/webstart"/>
92                 <!-- build directory configuration -->
93                 <property name="libDir" value="lib"/>
94                 <property name="resourceDir" value="resources"/>
95                 <property name="helpDir" value="help"/>
96                 <property name="docDir" value="doc"/>
97                 <property name="sourceDir" value="src" />
98                 <property name="schemaDir" value="schemas" />
99                 <property name="outputDir" value="classes" />
100                 <property name="packageDir" value="dist" />
101                 <property name="outputJar" value="jalview.jar" />
102           <!-- Jalview Applet JMol Jar Dependency -->
103     <property name="jmolJar" value="Jmol-11.0.2.jar" />
104                 <property name="jalviewLiteJar" value="jalviewApplet.jar"/>
105                 <!-- switch to indicate if we should obfuscate jalviewLite -->
106                 <!--<property name="donotobfuscate" value="true"/> -->
107                                 
108                 <!-- Jalview Web Service Clients - see the comments in 'buildextclients' for details -->
109                 <property name="wsdl.File" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred?wsdl" />
110                 <property name="wsdl.Files" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/vamsas?wsdlFiles" />
111                 <property name="wsdl.MsaWS" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS?wsdl" />
112                 <property name="wsdl.MsaWS2" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS?wsdl" />
113                 <property name="WSInterf" value="MsaWS" />
114                 <property name="wsdl.Namespace" value="vamsas" />
115                 <property name="wsdl.ClientNS" value="ext.vamsas" />
116                 <!-- the class path for building the application -->
117                 <path id="build.classpath">
118                         <fileset dir="utils">
119                                 <include name="*.jar"/>
120                                 <include name="**/*.jar"/>
121                         </fileset>
122                         <fileset dir="${libDir}">
123                                 <include name="*.jar"/>
124                                 <include name="**/*.jar"/>
125                         </fileset>
126                         
127                 </path>
128                 <property name="source.dist.name" value="${basedir}/jalview-src.tar.gz"/>
129                 <!-- The Location of the java 1.1.8 jdk -->
130                 <property name="java118.home" value="C:\Sun\jdk1.1.8" />
131                 <property name="applet.jre.tools" value="${java118.home}/lib/classes.zip"/>
132                 <!-- jre for 1.4 version
133                 <property name="applet.jre.tools" value="${java.home}/lib/rt.jar"/>
134                 -->
135                 <!-- the classpath for building the 1.1 applet -->
136                 <path id="jalviewlite.deps">
137                         <fileset dir="${java118.home}">
138                                 <include name="lib/classes.zip"/>
139                         </fileset>
140                 <pathelement location="lib/${jmolJar}"/>
141           </path>
142         </target>
143
144
145         <taskdef classpath="utils/roxes-ant-tasks-1.2-2004-01-30.jar" resource="com/roxes/tools/ant/taskdefs.properties"/>
146         <target name="buildPropertiesFile" depends="init">
147                 <tstamp prefix="build">
148                         <format property="date" pattern="dd MMMM yyyy"/>
149                 </tstamp>
150                 <properties file="${outputDir}/.build_properties">
151                         <header>
152           ---Jalview Build Details---
153         </header>
154                         <property name="VERSION" value="${JALVIEW_VERSION}"/>
155                         <property name="BUILD_DATE" value="${build.date}"/>
156                 </properties>
157         </target>
158
159
160         <target name="clean" depends="init">
161                 <!-- not efficient yet. -->
162                 <delete dir="${outputDir}"/>
163         </target>
164
165         <target name="distclean" depends="init, clean">
166
167                 <echo message="REMOVING ALL BACKUP/AUTOSAVES!"/>
168                 <delete>
169                         <fileset dir=".">
170                                 <include name="${outputJar}"/>
171                                 <include name="#*#"/>
172                                 <include name="#*.*#"/>
173                                 <include name="**/#*#"/>
174                                 <include name="**/#*.*#"/>
175                                 <include name="*~"/>
176                                 <include name="*.*~"/>
177                                 <include name="**/*~"/>
178                                 <include name="**/*.*~"/>
179                         </fileset>
180                 </delete>
181         </target>
182
183         <target name="prepare" depends="init">
184                 <mkdir dir="${outputDir}"/>
185                 <copy todir="${outputDir}">
186                         <fileset dir=".">
187                                 <include name="${docDir}/**/*.*"/>
188                                 <include name="${helpDir}/**/*.*"/>
189                                 <include name="${libDir}/*.jar"/>
190                         </fileset>
191                         <fileset dir="${resourceDir}">
192                                 <include name="**/*.*"/>
193                         </fileset>
194                 </copy>
195         </target>
196
197         <target name="build" depends="prepare">
198                 <!-- not efficient yet. -->
199                 <javac source="1.4" target="1.4"
200         srcdir ="${sourceDir}"
201         destdir="${outputDir}"
202                                 debug="${javac.debug}"
203       classpathref="build.classpath">
204                         <exclude name="jalview/*applet*"/>
205                         <exclude name="com/stevesoft/**"/>
206                 </javac>
207         </target>
208         <target name="buildindices" depends="init, prepare"
209     unless="help.uptodate">
210                 <java
211       classname="com.sun.java.help.search.Indexer"
212       classpathref="build.classpath"
213       fork="true"
214       dir="${outputDir}/${helpDir}"
215       >
216                         <arg line="html"/>
217                 </java>
218         </target>
219
220         <target name="makefulldist" depends="makedist">
221                 <!-- the default keystore details might need to be edited here -->
222                 <signjar
223       storepass="${jalview.keystore.pass}"
224       keypass="${jalview.key.pass}"
225       keystore="${jalview.keystore}"
226       alias="${jalview.key}"
227       lazy="false"
228       verbose="false"
229       >
230
231                         <fileset dir="${packageDir}">
232                                 <include name="*.jar"/>
233                         </fileset>
234                 </signjar>
235                 <taskdef classpathref="build.classpath" resource="com/roxes/tools/ant/taskdefs.properties"/>
236
237                 <!--    codebase="http://www.jalview.org/jalview/webstart" -->
238                 <!-- href="jalview.jnlp" prevent hard-wired pickup of jnlp in certain javaws versions -->
239                 <jnlp toFile="${packageDir}/jalview.jnlp" 
240       codebase="${WebStartLocation}">
241                         <information>
242                                 <title>Jalview</title>
243                                 <vendor>The Barton Group</vendor>
244                                 <homepage href="http://www.jalview.org"/>
245                                 <description>Jalview Multiple Alignment Editor</description>
246                                 <description kind="short">Jalview</description>
247                                 <icon href="logo_big.gif"/>
248                                 <offline_allowed/>
249                                 <!--
250         <association mime-type="application-x/ext-file" extensions="fa"/>
251         <association mime-type="application-x/ext-file" extensions="fasta"/>
252         <association mime-type="application-x/ext-file" extensions="fastq"/>
253         <association mime-type="application-x/ext-file" extensions="blc"/>
254         <association mime-type="application-x/ext-file" extensions="msf"/>
255         <association mime-type="application-x/ext-file" extensions="pfam"/>
256         <association mime-type="application-x/ext-file" extensions="aln"/>
257         <association mime-type="application-x/ext-file" extensions="pir"/>
258         <association mime-type="application-x/ext-file" extensions="amsa"/>
259         -->
260                         </information>
261                         <resources>
262                                 <j2se version="1.4+"/>
263                                 <fileset dir="${packageDir}">
264                                         <include name="jalview.jar"/>
265                                 </fileset>
266                                 <fileset dir="${packageDir}">
267                                         <include name="*.jar"/>
268                                         <include name="*_*.jar"/>
269                                         <exclude name="jalview.jar"/>
270                                 </fileset>
271                                 <property name="jalview.version" value="${JALVIEW_VERSION}"/>
272                         </resources>
273                         <application_desc main_class="jalview.bin.Jalview">
274                         </application_desc>
275                         <security>
276                                 <all_permissions/>
277                         </security>
278                 </jnlp>
279         </target>
280         <target name="runenv" depends="init">
281                 <path id="run.classpath">
282                         <pathelement location="${outputDir}"/>
283                         <fileset dir="${outputDir}">
284                                 <include name="${libDir}/*.jar"/>
285                         </fileset>
286                 </path>
287                 <pathconvert targetos="unix" refid="run.classpath" property="run.classpath"/>
288
289                 <echo>java -classpath ${run.classpath} jalview.bin.Jalview
290       </echo>
291         </target>
292
293         <target name="buildextclients" depends="init">
294                 <input message="Building external client source from WSDLs - Do you really want to do this ? (Yy/Nn)"
295       validargs="Y,y,n,N" defaultvalue="N"
296       addproperty="doextbuild.response"/>
297                 <condition property="dontextbuild">
298                         <equals arg1="n" arg2="${doextbuild.response}"/>
299                 </condition>
300                 <condition property="dontextbuild">
301                         <equals arg1="N" arg2="${doextbuild.response}"/>
302                 </condition>
303                 <fail if="dontextbuild">
304         Build External Client Code process aborted by user. Jalview source is unchanged.
305       </fail>
306                 <!-- Currently, this doesn't happen automatically.
307      1. Run WSDL2Java as below, which generates an ext.vamsas +
308      vamsas.<datapackages> fileset.
309      2. refactor ext.vamsas.SpecificserviceWS* to
310      ext.vamsas.ServiceclassWS* that implements the ServiceclassWSI interface.
311      3. Update the jalview.ws.*WServices classes to reflect the
312      interface type, and all locations of this wsdl type that Jalview
313      might be using.
314
315 -->
316                 <path id="axisbuild">
317                         <path refid="build.classpath"/>
318                 </path>
319                 <taskdef resource="axis-tasks.properties" classpathref="axisbuild"/>
320                 <move todir="./bak">
321                         <fileset dir="${sourceDir}" id="client">
322                                 <include name="${wsdl.ClientNS}/*.*"/>
323                         </fileset>
324                 </move>
325
326                 <axis-wsdl2java
327       output="${sourceDir}"
328       verbose="true"
329       url="${wsdl.MsaWS2}"
330       serverside="false"
331       deployscope="Request"
332       debug="false"
333       helpergen="true"
334       all="true"
335       >
336                         <mappingSet>
337                                 <mapping
338         namespace="${wsdl.Namespace}"
339         package="${wsdl.ClientNS}"
340         />
341                                 <mapping namespace="http://dataTypes.vamsas"
342         package="${wsdl.ClientNS}"/>
343                         </mappingSet>
344                 </axis-wsdl2java>
345         </target>
346
347         <target name="makedist" depends="build, buildPropertiesFile, buildindices">
348                 <!-- make the package jar -->
349                 <mkdir dir="${packageDir}"/>
350
351                 <jar destfile="${packageDir}/${outputJar}">
352                         <manifest>
353                                 <attribute name="Main-Class" value="jalview.bin.Jalview"/>
354                         </manifest>
355                         <fileset dir="${outputDir}/">
356                                 <exclude name="cache*/**"/>
357                                 <exclude name="*.jar" />
358                                 <exclude name="*.jar.*" />
359                                 <exclude name="**/*.jar" />
360                                 <exclude name="**/*.jar.*" />
361                         </fileset>
362                 </jar>
363
364                 <copy toDir="${packageDir}" flatten="true">
365                         <fileset dir="${outputDir}">
366                                 <include name="*.jar"/>
367                                 <include name="**/*.jar"/>
368                         </fileset>
369                 </copy>
370         </target>
371
372
373         <!-- jalopy code reformatter -->
374         <target name="sourcescrub" depends="init,build">
375                 <jalopy destdir="jsrc" classpathref="run.classpath"
376       convention="jalview-jalopy.xml">
377                         <fileset dir="${sourceDir}">
378                                 <include name="*.java"/>
379                                 <include name="**/*.java"/>
380                                 <include name="**/**/*.java"/>
381                         </fileset>
382                 </jalopy>
383         </target>
384
385
386
387   <!-- Compile, package and obfuscate Jalview Applet -->
388   <target name="makeApplet" depends="obfuscate"/>
389
390   <target name="compileApplet" depends="init,clean">
391     <mkdir dir="${outputDir}"/>
392     <javac source="1.2"
393     target="1.1"
394     srcdir="${sourceDir}" 
395     destdir="${outputDir}"
396         debug="${javac.debug}"
397     classpath="lib/${jmolJar}"
398        includes="jalview/appletgui/**"
399        excludes="ext/**,MCview/**,org/**,vamsas/**"
400        />
401   </target>
402
403   <target name="packageApplet" depends="compileApplet, buildPropertiesFile">
404   <copy file="${resourceDir}/images/idwidth.gif" toFile="${outputDir}/images/idwidth.gif"/>
405   <copy file="${resourceDir}/images/link.gif" toFile="${outputDir}/images/link.gif"/>
406        <jar destfile="in.jar">
407         <manifest>
408             <attribute name="Main-Class" value="jalview.bin.JalviewLite"/>
409         </manifest>
410         <fileset dir="${outputDir}">
411           <include name="com/**"/>
412           <include name="MCview/**"/>
413           <include name="jalview/**"/>
414           <include name=".build_properties"/>
415           <include name="images/idwidth.gif"/>
416           <include name="images/link.gif"/>
417         </fileset>
418       </jar>
419   </target>
420   <target name="obfuscate" depends="-obfuscatefake,-obfuscatereally" description="construct the final jalviewLite applet jar with or without obfuscation">
421   </target>
422         <target name="-obfuscatefake" depends="packageApplet" if="donotobfuscate">    
423         <copy file="in.jar" tofile="${jalviewLiteJar}" />       
424     <delete file="in.jar"/>
425   </target>
426         <target name="-obfuscatereally" unless="donotobfuscate">
427     
428         <path id="obfuscateDeps.path">
429     <pathelement location="${applet.jre.tools}"/>
430     <pathelement location="lib/${jmolJar}"/>
431     </path>
432     <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard.jar" />
433         
434     <proguard>
435       <injar file="in.jar"/>
436       <outjar file="${jalviewLiteJar}"/>
437       <libraryjar refid="obfuscateDeps.path"/>
438       <keep access="public" type="class"
439       name="jalview.bin.JalviewLite">
440         <field access="public"/>
441         <method access="public"/>
442         <constructor access="public"/>
443       </keep>
444 <!--      -libraryjars "${obfuscateDeps}"
445       -injars      in.jar
446       -outjars     jalviewApplet.jar
447       -keep public class jalview.bin.JalviewLite
448        { public * ; } -->
449       </proguard>
450     <delete file="in.jar"/>
451   </target>
452
453         <target name="castorbinding" depends="init" description="Generate Java bindings to supported Jalview XML models.">
454                 <taskdef name="castor-srcgen"
455                           classname="org.castor.anttask.CastorCodeGenTask"
456                       classpathref="build.classpath" />
457                 <delete>
458                         <fileset dir="${sourceDir}/jalview/schemabinding/version2">
459                                 <include name="*.java"/>
460                                 <include name="descriptors/*.java"/>
461                         </fileset>
462                 </delete>
463                 <castor-srcgen file="${schemaDir}/vamsas.xsd"
464                               todir="${sourceDir}"
465                               package="jalview.schemabinding.version2"
466                               warnings="false" 
467                                         nodesc="false"
468                                                 verbose="true"
469                                                 properties="${schemaDir}/jalview.properties"
470                 />
471                 <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd"
472                               todir="${sourceDir}"
473                               package="jalview.schemabinding.version2"
474                               warnings="false" 
475                                         nodesc="false"
476                                                 verbose="true"
477                                                 properties="${schemaDir}/jalview.properties"
478                 />
479                 <castor-srcgen file="${schemaDir}/jalview.xsd"
480                               todir="${sourceDir}"
481                               package="jalview.schemabinding.version2"
482                               warnings="false" 
483                                           nodesc="false"
484                                                 verbose="true"
485                                                 properties="${schemaDir}/jalview.properties"
486                         
487                 />
488                 <!-- 
489                 now build the jalview.binding package with the old schema set
490                 -->
491                 <delete>
492                         <fileset dir="${sourceDir}/jalview/binding/">
493                                 <include name="**"/>
494                         </fileset>
495                 </delete>
496                 <castor-srcgen file="${schemaDir}/vamsasJvV1.xsd"
497                               todir="${sourceDir}"
498                               package="jalview.binding"
499                               warnings="false" 
500                                         nodesc="true"
501                                                 verbose="true"
502                                                 properties="${schemaDir}/jalview.nodesc.properties"
503                 /> 
504                 <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd"
505                               todir="${sourceDir}"
506                               package="jalview.binding"
507                               warnings="false" 
508                                         nodesc="true"
509                                                 verbose="true"
510                                                 properties="${schemaDir}/jalview.nodesc.properties"
511                 />
512                 <castor-srcgen file="${schemaDir}/jalviewJvV1.xsd"
513                               todir="${sourceDir}"
514                               package="jalview.binding"
515                               warnings="false" 
516                                           nodesc="true"
517                                                 verbose="true"
518                                                 properties="${schemaDir}/jalview.nodesc.properties"
519         />
520         </target>
521         <target name="sourcedist" description="create jalview source distribution" depends="init">
522                 <delete file="${source.dist.name}"/>
523                 <tar destfile="${source.dist.name}" compression="gzip">
524                         <tarfileset dir="./" prefix="jalview" preserveLeadingSlashes="true">
525                                 <include name="LICENSE"/>
526                                 <include name="README"/>
527                                 <include name="build.xml"/>
528                                 <include name="jalview-jalopy.xml"/>
529                                 <include name="JalviewApplet.jpx"/>
530                                 <include name="JalviewX.jpx"/>
531                                 <include name="${sourceDir}/*.java"/>
532                                 <include name="${sourceDir}/**/*.java"/>
533                                 <include name="${sourceDir}/**/*.cdr"/>
534                                 <include name="${libDir}/**/*"/>                                                
535                                 <include name="${resourceDir}/**/*"/>                                           
536                                 <include name="${helpDir}/**/*"/>                                               
537                                 <exclude name="**/*locales"/>
538                                 <exclude name="*locales/**"/>
539                                 <exclude name="utils/InstallAnywhere/**Build.iap_xml"/>
540                                 <exclude name="utils/InstallAnywhere/**Build*/**"/>
541                                 <exclude name="utils/InstallAnywhere/**Build*/**"/>
542                                 <exclude name="utils/InstallAnywhere/**locale*"/>
543                                 <exclude name="utils/InstallAnywhere/**locale*/**"/>
544                                 <include name="${schemaDir}/**/*"/>                                             
545                                 <include name="utils/**/*"/>
546                                 <include name="${docDir}/**/*"/>                                                
547                         </tarfileset>
548                 </tar>
549         </target>
550 </project>