e9006caf7e966c25b30b812efd46bb3e4dfdb148
[jalview.git] / build.xml
1 <?xml version="1.0"?>
2 <!--
3  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
4  * Copyright (C) $$Year-Rel$$ The Jalview Authors
5  * 
6  * This file is part of Jalview.
7  * 
8  * Jalview is free software: you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License 
10  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
18  * The Jalview Authors are detailed in the 'AUTHORS' file.
19 -->
20 <project name="jalviewX" default="usage" basedir=".">
21   <target name="help" depends="usage" />
22   <target name="usage">
23     <echo message="~~~Jalview Ant build.xml Usage~~~~" />
24     <echo message="Targets include:" />
25     <echo message="usage - default target, displays this message" />
26     <echo message="buildindices - generates JavaHelpSearch from the help files" />
27     <echo message="build - compiles all necessary files for Application" />
28     <echo message="makedist - compiles and places all necessary jar files into directory dist" />
29     <echo message="makefulldist - signs all jar files and builds jnlp file for full distribution" />
30     <echo message="              this needs a keystore and key. See docs/building.html for more information." />
31     <echo message="compileApplet - compiles all necessary files for Applet" />
32     <echo message="makeApplet - compiles, then packages and obfuscates the Applet" />
33     <echo message="See docs/building.html and the comments in build file for other targets." />
34     <echo message="note: compile and makeApplet require the property java118.home to be set to point to a java 1.1.8 jdk." />
35     <echo message="Useful -D flags: -Ddonotobfuscate will prevent applet obfuscation" />
36   </target>
37
38
39   <!-- utils is a class path to additional utilities needed for
40     building docs, jars and webstart stuff -->
41   <!--
42         Userdefined build property defaults
43
44         wsdl.server list (plus namespace mapping info ???)  - also want
45                 ... to make this a dynamically generatable property
46         WebStart Location
47         Build location - provide a temporary root for speed
48         jarsigner keystore and info
49         Jakarta and axis classpath ?
50         Default argument for starting Jalview (if it exists).
51
52 -->
53
54   <target name="init">
55     <path id="axis.classpath">
56       <!-->
57       <fileset dir="/usr/local/axis/lib">
58         <include name="**/*.jar" />
59       </fileset>
60       <fileset dir="/usr/local/jakarta-tomcat-5/webapps/axis/WEB-INF/lib">
61         <include name="**/*.jar"/>
62         <include name="*.jar"/>
63       </fileset> -->
64       </path>
65         
66     <!-- Jalview Version String displayed by application on startup and used to check for updates -->
67     <property name="JALVIEW_VERSION" value="DEVELOPMENT" />
68         
69     <property name="INSTALLATION" value="Source" />
70         
71     <!-- 2.4 (VAMSAS)" -->
72     <!-- Include debugging information in javac true or false -->
73     <property name="javac.debug" value="true" />
74
75     <!-- JarSigner Key Store for Webstart Distribution -->
76     <property name="jalview.keystore" value="./keys/.keystore" />
77     <!-- Keystore Password -->
78     <property name="jalview.keystore.pass" value="alignmentisfun" />
79     <!-- Key Name -->
80     <property name="jalview.key" value="jalview" />
81     <!-- Key Password -->
82     <property name="jalview.key.pass" value="alignmentisfun" />
83
84     <!-- Don't change anything below here unless you know what you are doing! -->
85     <!-- Url path for WebStart in JNLP file -->
86     <property name="WebStartLocation" value="http://www.jalview.org/webstart" />
87     <!-- Webstart Image - looked for in resources/images -->
88     <property name="WebStartImage" value="JalviewLogo_big.png"/>
89     <!-- J2SE version needed for webstart launch -->
90     <!-- Anne's version needs 1.7 - should rebuild VARNA to java 1.6 for release -->
91     <property name="j2sev" value="1.7+"/>
92         <!-- Java Compilation settings - source and target javac version -->
93         <property name="javac.source" value="1.7"/>
94         <property name="javac.target" value="1.7"/>
95                 
96     <!-- Permissions for running Java applets and applications. -->
97     <!-- Defaults are those suitable for deploying jalview webstart www.jalview.org -->
98     <property name="application.codebase" value="*.jalview.org" />
99     <!-- and allowing the applet to be deployed from any URL -->
100     <!-- note - if you want to make sure LiveConnect works without any warnings, please rebuild and sign your applet jar with your own domain included in the codebase/allowable-codebase properties -->
101     <property name="applet.codebase" value="*.jalview.org *.dundee.ac.uk *" />
102     <property name="applet.caller-codebase" value="${applet.codebase}" />
103
104     <!-- build directory configuration -->
105     <property name="libDir" value="lib" />
106     <property name="resourceDir" value="resources" />
107     <property name="helpDir" value="help" />
108     <property name="docDir" value="doc" />
109     <property name="sourceDir" value="src" />
110     <property name="schemaDir" value="schemas" />
111     <property name="outputDir" value="classes" />
112     <property name="packageDir" value="dist" />
113     <property name="outputJar" value="jalview.jar" />
114     <!-- Jalview Applet JMol Jar Dependency -->
115     <property name="jmolJar" value="JmolApplet-14.2.14_2015.06.11.jar" />
116     <property name="varnaJar" value="VARNAv3-93.jar" />
117     <property name="jsoup" value="jsoup-1.8.1.jar" />
118     <property name="jsonSimple" value="json_simple-1.1.jar" />
119     <property name="javaJson" value="java-json.jar" />
120     <property name="jalviewLiteJar" value="jalviewApplet.jar" />
121         <property name="reportDir" value="test-reports" />
122         <property name="testDir" value="test" />
123         <property name="testOutputDir" value="tests" />
124     <!-- switch to indicate if we should obfuscate jalviewLite -->
125     <!-- <property name="donotobfuscate" value="true"/> -->
126     <!-- switch to exclude associations from generated jnlp files -->
127     <!-- <property name="nojnlpfileassocs" value="true"/> -->
128
129     <!-- Jalview Web Service Clients - see the comments in 'buildextclients' for details -->
130     <property name="wsdl.File" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred?wsdl" />
131     <property name="wsdl.Files" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/vamsas?wsdlFiles" />
132     <property name="wsdl.MsaWS" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS?wsdl" />
133     <property name="wsdl.MsaWS2" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS?wsdl" />
134     <property name="WSInterf" value="MsaWS" />
135     <property name="wsdl.Namespace" value="vamsas" />
136     <property name="wsdl.ClientNS" value="ext.vamsas" />
137     <!-- the class path for building the application -->
138     <path id="build.classpath">
139       <fileset dir="utils">
140         <include name="*.jar" />
141         <include name="**/*.jar" />
142       </fileset>
143       <fileset dir="${libDir}">
144         <include name="*.jar" />
145         <include name="**/*.jar" />
146       </fileset>
147       <fileset dir="${java.home}/lib">
148         <include name="plugin.jar"/>
149       </fileset>
150       <fileset dir="appletlib">
151         <!-- the JmolApplet includes the JmolApplet console and the application javac seems to always try and build all packages 
152                                 -->
153         <include name="${jmolJar}" />
154         <include name="${varnaJar}" />
155       </fileset>
156
157     </path>
158     <property name="source.dist.name" value="${basedir}/jalview-src.tar.gz" />
159     <!-- The Location of the java 1.1.8 jdk -->
160     <!--<property name="java118.home" value="C:\Sun\jdk1.1.8" /> -->
161     <property name="java118.home" value="${java.home}" />
162     <!-- <property name="applet.jre.tools" value="${java118.home}/lib/classes.zip" />
163                 -->
164     <!-- jre for 1.4 version -->
165     <property name="applet.jre.tools" value="${java.home}/lib/rt.jar"/>
166
167     <!-- the classpath for building the 1.1 applet -->
168     <path id="jalviewlite.deps">
169       <fileset dir="${java118.home}">
170         <include name="lib/classes.zip" />
171       </fileset>
172       <fileset dir="${java.home}/lib">
173         <include name="plugin.jar"/>
174       </fileset>
175       <pathelement location="appletlib/${jmolJar}" />
176       <pathelement location="lib/${varnaJar}" />
177       <pathelement location="lib/${jsoup}" />
178       <pathelement location="lib/${jsonSimple}" />
179       <pathelement location="lib/${javaJson}" />
180       
181     </path>
182     <!-- default location for outputting javadoc -->
183     <property name="javadocDir" value="${packageDir}/javadoc"/>
184   </target>
185
186
187   <taskdef classpath="utils/roxes-ant-tasks-1.2-2004-01-30.jar" resource="com/roxes/tools/ant/taskdefs.properties" />
188   <target name="buildPropertiesFile" depends="init">
189     <tstamp prefix="build">
190       <format property="date" pattern="dd MMMM yyyy" />
191     </tstamp>
192     <exec executable="/usr/bin/git" outputproperty="git.commit"  failifexecutionfails="false">
193       <arg value="rev-parse"/>
194       <arg value="--short"/>
195       <arg value="HEAD"/>
196     </exec>
197     <exec executable="/usr/bin/git" outputproperty="git.branch" failifexecutionfails="false">
198       <arg value="rev-parse"/>
199       <arg value="--abbrev-ref"/>
200       <arg value="HEAD"/>
201     </exec>
202     <properties file="${outputDir}/.build_properties">
203       <header>
204           ---Jalview Build Details---
205         </header>       
206       <property name="VERSION" value="${JALVIEW_VERSION}" />
207       <property name="INSTALLATION" value="${INSTALLATION} git-commit:${git.commit} [${git.branch}]" />
208       <property name="BUILD_DATE" value="${build.date}" />
209     </properties>
210   </target>
211
212
213   <target name="clean" depends="init">
214     <!-- not efficient yet. -->
215     <delete dir="${outputDir}" includes="*,**/*"/>
216   </target>
217
218   <target name="distclean" depends="init, clean">
219
220     <echo message="REMOVING ALL BACKUP/AUTOSAVES!" />
221     <delete>
222       <fileset dir=".">
223         <include name="${outputJar}" />
224         <include name="#*#" />
225         <include name="#*.*#" />
226         <include name="**/#*#" />
227         <include name="**/#*.*#" />
228         <include name="*~" />
229         <include name="*.*~" />
230         <include name="**/*~" />
231         <include name="**/*.*~" />
232       </fileset>
233     </delete>
234   </target>
235
236   <target name="prepare" depends="init">
237     <mkdir dir="${outputDir}" />
238     <copy todir="${outputDir}">
239       <fileset dir=".">
240         <include name="${docDir}/**/*.*" />
241         <include name="${helpDir}/**/*.*" />
242         <include name="${libDir}/*.jar" />
243       </fileset>
244       <fileset dir="${resourceDir}">
245         <include name="**/*.*" />
246       </fileset>
247     </copy>
248   </target>
249
250   <target name="build" depends="prepare">
251     <!-- not efficient yet. -->
252     <javac source="${javac.source}" target="${javac.target}" srcdir="${sourceDir}" destdir="${outputDir}" debug="${javac.debug}" classpathref="build.classpath">
253       <exclude name="jalview/*applet*" />
254       <exclude name="jalview/appletgui/**" />
255       <exclude name="com/stevesoft/**" />
256     </javac>
257   </target>
258   
259   
260   <target name="testclean" depends="init">
261     <delete dir="${testOutputDir}" includes="*,**/*"/>
262   </target>
263   
264   <target name="prepareTests" depends="init">
265         <mkdir dir="${testOutputDir}" />
266         <copy todir="${testOutputDir}">
267                 <fileset dir=".">
268                         <include name="${docDir}/**/*.*" />
269                         <include name="${helpDir}/**/*.*" />
270                         <include name="${libDir}/*.jar" />
271                 </fileset>
272                 <fileset dir="${resourceDir}">
273                         <include name="**/*.*" />
274                 </fileset>
275         </copy>
276   </target>  
277   
278   <target name="buildTests" depends="prepareTests">
279         <javac source="${javac.source}" target="${javac.target}" srcdir="${sourceDir}" destdir="${testOutputDir}"
280                 debug="${javac.debug}" classpathref="build.classpath" includeantruntime="false" >               
281         </javac>
282         <javac source="${javac.source}" target="${javac.target}" srcdir="${testDir}" destdir="${testOutputDir}"
283                 debug="${javac.debug}" classpathref="build.classpath" includeantruntime="false" >
284         </javac>
285   </target>
286   
287   <taskdef name="testng" classname="org.testng.TestNGAntTask" >     
288         <classpath location="utils/testnglibs/testng.jar" />
289   </taskdef>
290   
291   <target name="testng" depends="buildTests">
292         <testng classpathref="build.classpath" outputDir="${reportDir}"
293                 haltOnFailure="false">
294                 <classpath location="${testOutputDir}" />
295                 <xmlfileset dir="utils" includes="jalview_testng.xml" />
296         </testng>
297   </target>
298   
299   <target name="buildindices" depends="init, prepare" unless="help.uptodate">
300     <java classname="com.sun.java.help.search.Indexer" classpathref="build.classpath" fork="true" dir="${outputDir}/${helpDir}">
301       <arg line="html" />
302     </java>
303   </target>
304
305   <target name="makefulldist" depends="makedist">
306     <copy todir="${packageDir}">
307       <fileset dir="${resourceDir}/images">
308         <include name="${WebStartImage}"/>
309       </fileset>
310     </copy>
311
312     <taskdef classpathref="build.classpath" resource="com/roxes/tools/ant/taskdefs.properties" />
313
314     <!-- create a dummy jar which will eventually contain the jnlp template -->
315     <jar destfile="${packageDir}/jalview_jnlp_vm.jar" index="true">
316       <fileset dir="${packageDir}">
317         <include name="jalview.jar" />
318       </fileset>
319     </jar>
320
321     <mkdir dir="${packageDir}/JNLP-INF"/>
322     <antcall target="writejnlpf">
323       <param name="jnlpFile" value="${packageDir}/JNLP-INF/APPLICATION-TEMPLATE.JNLP"/>
324       <param name="inih" value="*" />
325       <param name="maxh" value="*"/>
326     </antcall>
327
328     <jar destfile="${packageDir}/jalview_jnlp_vm.jar" index="true">
329       <fileset dir="${packageDir}">
330         <include name="JNLP-INF"/>
331       </fileset>
332     </jar>
333
334     <antcall target="writejnlpf">
335       <param name="jnlpFile" value="${packageDir}/jalview.jnlp"/>
336       <param name="inih" value="10M" />
337       <param name="maxh" value="256M"/>
338     </antcall>
339
340     <antcall target="writejnlpf">
341       <param name="jnlpFile" value="${packageDir}/jalview_1G.jnlp"/>
342       <param name="inih" value="128M" />
343       <param name="maxh" value="512M"/>
344     </antcall>
345
346     <antcall target="writejnlpf">
347       <param name="jnlpFile" value="${packageDir}/jalview_2G.jnlp"/>
348       <param name="inih" value="256M" />
349       <param name="maxh" value="1024M"/>
350     </antcall>
351
352     <!-- finally, need to postprocess to add in associations at end of 'information' element 
353                         
354                         <xslt in="${packageDir}/jalview_noa_1G.jnlp" out="${packageDir}/jalview_1G.jnlp">
355                 
356                 </xslt>
357                         
358                         
359                         -->
360     <!--
361                                 <association mime-type="application-x/ext-file" extensions="fa"/>
362         <association mime-type="application-x/ext-file" extensions="fasta"/>
363         <association mime-type="application-x/ext-file" extensions="mfa"/>
364         <association mime-type="application-x/ext-file" extensions="fastq"/>
365         <association mime-type="application-x/ext-file" extensions="blc"/>
366         <association mime-type="application-x/ext-file" extensions="msf"/>
367         <association mime-type="application-x/ext-file" extensions="pfam"/>
368         <association mime-type="application-x/ext-file" extensions="aln"/>
369         <association mime-type="application-x/ext-file" extensions="pir"/>
370         <association mime-type="application-x/ext-file" extensions="amsa"/>
371         <association mime-type="application-x/ext-file" extensions="stk"/>
372         <association mime-type="application-x/ext-file" extensions="jar"/>-->
373     <!-- and sign the jars -->
374     <!-- the default keystore details might need to be edited here -->
375     <signjar storepass="${jalview.keystore.pass}" keypass="${jalview.key.pass}" keystore="${jalview.keystore}" alias="${jalview.key}" lazy="false" verbose="false" sigalg="SHA1withRSA">
376       <fileset dir="${packageDir}">
377         <include name="*.jar" />
378       </fileset>
379     </signjar>
380   </target>
381
382   <target name="runenv" depends="init">
383     <path id="run.classpath">
384       <pathelement location="${outputDir}" />
385       <fileset dir="${outputDir}">
386         <include name="${libDir}/*.jar" />
387       </fileset>
388     </path>
389     <pathconvert targetos="unix" refid="run.classpath" property="run.classpath" />
390
391     <echo>java -classpath ${run.classpath} jalview.bin.Jalview
392       </echo>
393   </target>
394
395   <target name="-generatejnlpf">
396     <presetdef name="jnlpf">
397       <jnlp codebase="${WebStartLocation}">
398         <information>
399           <title>Jalview</title>
400           <vendor>The Barton Group</vendor>
401           <homepage href="http://www.jalview.org" />
402           <description>Jalview Multiple Alignment Editor</description>
403           <description kind="short">Jalview</description>
404           <icon href="${WebStartImage}" />
405           <offline_allowed />
406         </information>
407         <resources>
408           <j2se version="${j2sev}" initial_heap_size="${inih}" max_heap_size="${maxh}" />
409           <fileset dir="${packageDir}">
410             <include name="jalview.jar" />
411           </fileset>
412           <fileset dir="${packageDir}">
413             <include name="*.jar" />
414             <include name="*_*.jar" />
415             <exclude name="jalview.jar" />
416                 <exclude name="*jnilib.jar"/>
417           </fileset>
418         </resources>
419         <resources os="Mac OS X">
420           <property name="jalview.version" value="${JALVIEW_VERSION}" />
421                 <fileset dir="${packageDir}">
422                         <include name="*quaqua*.jnilib.jar"/>
423                 </fileset>
424         </resources>
425         
426         <application_desc main_class="jalview.bin.Jalview">
427         </application_desc>
428         <security>
429           <all_permissions />
430         </security>
431       </jnlp>
432     </presetdef>
433
434     <jnlpf toFile="${jnlpFile}"/>
435
436   </target>
437
438   <target name="-dofakejnlpfileassoc" depends="-generatejnlpf" if="nojnlpfileassocs">
439     <echo message="Not adding JNLP File Associations"/>
440   </target>
441
442   <target name="-dojnlpfileassoc" depends="-generatejnlpf" unless="nojnlpfileassocs">
443     <replace file="${jnlpFile}">
444       <replacetoken>
445         <![CDATA[</information>]]></replacetoken>
446       <replacevalue>
447         <![CDATA[
448           <association mime-type="application-x/ext-file" extensions="fa" />
449         <association mime-type="application-x/ext-file" extensions="fasta" />
450         <association mime-type="application-x/ext-file" extensions="mfa" />
451         <association mime-type="application-x/ext-file" extensions="fastq" />
452         <association mime-type="application-x/ext-file" extensions="blc" />
453         <association mime-type="application-x/ext-file" extensions="msf" />
454         <association mime-type="application-x/ext-file" extensions="pfam" />
455         <association mime-type="application-x/ext-file" extensions="aln"/>
456         <association mime-type="application-x/ext-file" extensions="pir"/>
457         <association mime-type="application-x/ext-file" extensions="amsa"/>
458         <association mime-type="application-x/ext-file" extensions="stk"/>
459         <association mime-type="application-x/ext-file" extensions="jvp"/>
460       </information>]]></replacevalue>
461   </replace>
462   <echo message="Added file associations to JNLP file"/>
463 </target>
464 <target name="writejnlpf" depends="-dojnlpfileassoc,-dofakejnlpfileassoc">
465 </target>
466
467 <target name="buildextclients" depends="init">
468   <input message="Building external client source from WSDLs - Do you really want to do this ? (Yy/Nn)" validargs="Y,y,n,N" defaultvalue="N" addproperty="doextbuild.response" />
469   <condition property="dontextbuild">
470     <equals arg1="n" arg2="${doextbuild.response}" />
471   </condition>
472   <condition property="dontextbuild">
473     <equals arg1="N" arg2="${doextbuild.response}" />
474   </condition>
475   <fail if="dontextbuild">
476         Build External Client Code process aborted by user. Jalview source is unchanged.
477       </fail>
478   <!-- Currently, this doesn't happen automatically.
479      1. Run WSDL2Java as below, which generates an ext.vamsas +
480      vamsas.<datapackages> fileset.
481      2. refactor ext.vamsas.SpecificserviceWS* to
482      ext.vamsas.ServiceclassWS* that implements the ServiceclassWSI interface.
483      3. Update the jalview.ws.*WServices classes to reflect the
484      interface type, and all locations of this wsdl type that Jalview
485      might be using.
486
487 -->
488   <path id="axisbuild">
489     <path refid="build.classpath" />
490   </path>
491   <taskdef resource="axis-tasks.properties" classpathref="axisbuild" />
492   <move todir="./bak">
493     <fileset dir="${sourceDir}" id="client">
494       <include name="${wsdl.ClientNS}/*.*" />
495     </fileset>
496   </move>
497
498   <axis-wsdl2java output="${sourceDir}" verbose="true" url="${wsdl.MsaWS2}" serverside="false" deployscope="Request" debug="false" helpergen="true" all="true">
499     <mappingSet>
500       <mapping namespace="${wsdl.Namespace}" package="${wsdl.ClientNS}" />
501       <mapping namespace="http://dataTypes.vamsas" package="${wsdl.ClientNS}" />
502     </mappingSet>
503   </axis-wsdl2java>
504 </target>
505
506 <target name="makedist" depends="build, buildPropertiesFile, buildindices">
507   <!-- make the package jar if not already existing -->
508   <mkdir dir="${packageDir}" />
509   <!-- clean dir if it already existed -->
510   <delete>
511     <fileset dir="${packageDir}">
512       <include name="*.jar"/>
513     </fileset>
514   </delete>
515   <jar destfile="${packageDir}/${outputJar}" index="true">
516     <manifest>
517       <attribute name="Main-Class" value="jalview.bin.Jalview" />
518       <attribute name="Permissions" value="all-permissions" />
519       <attribute name="Application-Name" value="Jalview Desktop" />
520       <attribute name="Codebase" value="${application.codebase}" />
521     </manifest>
522     <fileset dir="${outputDir}/">
523       <exclude name="cache*/**" />
524       <exclude name="*.jar" />
525       <exclude name="*.jar.*" />
526       <exclude name="**/*.jar" />
527       <exclude name="**/*.jar.*" />
528     </fileset>
529   </jar>
530
531   <copy toDir="${packageDir}" flatten="true">
532     <fileset dir="${outputDir}">
533       <include name="*.jar" />
534       <include name="**/*.jar" />
535     </fileset>
536   </copy>
537 </target>
538
539
540 <!-- jalopy code reformatter -->
541 <target name="sourcescrub" depends="init,build">
542   <jalopy destdir="jsrc" classpathref="run.classpath" convention="jalview-jalopy.xml">
543     <fileset dir="${sourceDir}">
544       <include name="*.java" />
545       <include name="**/*.java" />
546       <include name="**/**/*.java" />
547     </fileset>
548   </jalopy>
549 </target>
550
551
552
553 <!-- Compile, package and obfuscate Jalview Applet -->
554 <target name="makeApplet" depends="obfuscate" description="assemble the final jalviewLite applet jar with or without obfuscation"/>
555
556 <target name="compileApplet" depends="init,clean">
557   <mkdir dir="${outputDir}" />
558   <javac source="${javac.source}" target="${javac.target}" srcdir="${sourceDir}" destdir="${outputDir}" debug="${javac.debug}" 
559                         classpathref="jalviewlite.deps" includes="jalview/appletgui/**"
560                         excludes="ext/**,gui/**,jbgui/**,MCview/**,org/**,vamsas/**,jalview/ext/rbvi/**,jalview/ext/paradise/**" />
561 </target>
562
563 <target name="packageApplet" depends="compileApplet, buildPropertiesFile">
564   <copy file="${resourceDir}/images/idwidth.gif" toFile="${outputDir}/images/idwidth.gif" />
565   <copy file="${resourceDir}/images/link.gif" toFile="${outputDir}/images/link.gif" />
566   <copy todir="${outputDir}/lang">
567     <fileset dir="${resourceDir}/lang">
568       <include name="**.*"/>
569     </fileset>
570   </copy>
571   <jar destfile="in.jar" index="true">
572     <manifest>
573       <attribute name="Main-Class" value="jalview.bin.JalviewLite" />
574       <attribute name="Application-Name" value="JalviewLite" />
575       <attribute name="Codebase" value="${applet.codebase}" />
576     </manifest>
577     <fileset dir="${outputDir}">
578       <include name="com/**" />
579       <include name="MCview/**" />
580       <include name="jalview/**" />
581       <include name=".build_properties" />
582       <include name="images/idwidth.gif" />
583       <include name="images/link.gif" />
584       <include name="lang/**" />
585     </fileset>
586   </jar>
587 </target>
588 <target name="obfuscate" depends="-obfuscatefake,-obfuscatereally">
589 </target>
590 <target name="-obfuscatefake" depends="packageApplet" if="donotobfuscate">
591   <copy file="in.jar" tofile="${jalviewLiteJar}" overwrite="true" />
592   <delete file="in.jar" />
593 </target>
594 <target name="-obfuscatereally" unless="donotobfuscate">
595
596   <path id="obfuscateDeps.path">
597     <pathelement location="${applet.jre.tools}" />
598     <pathelement location="appletlib/${jmolJar}" />
599     <pathelement location="appletlib/${jsonSimple}" />
600     <pathelement location="appletlib/${javaJson}" />
601   </path>
602   <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard.jar" />
603
604   <proguard>
605     <injar file="in.jar" />
606     <outjar file="${jalviewLiteJar}" />
607     <libraryjar refid="obfuscateDeps.path" />
608     <dontwarn/>
609     <keep access="public" type="class" name="jalview.bin.JalviewLite">
610       <field access="public" />
611       <method access="public" />
612       <constructor access="public" />
613     </keep>
614     <keep access="public" type="class" name="jalview.appletgui.AlignFrame">
615       <field access="public" />
616       <method access="public" />
617       <constructor access="public" />
618     </keep>
619     <!--      -libraryjars "${obfuscateDeps}"
620       -injars      in.jar
621       -outjars     jalviewApplet.jar
622       -keep public class jalview.bin.JalviewLite
623        { public * ; } -->
624   </proguard>
625   <delete file="in.jar" />
626 </target>
627
628 <target name="castorbinding" depends="init" description="Generate Java bindings to supported Jalview XML models.">
629   <taskdef name="castor-srcgen" classname="org.castor.anttask.CastorCodeGenTask" classpathref="build.classpath" />
630   <delete>
631     <fileset dir="${sourceDir}/jalview/schemabinding/version2">
632       <include name="*.java" />
633       <include name="descriptors/*.java" />
634     </fileset>
635   </delete>
636   <castor-srcgen file="${schemaDir}/vamsas.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
637   <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
638   <castor-srcgen file="${schemaDir}/JalviewWsParamSet.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
639   <castor-srcgen file="${schemaDir}/jalview.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
640   <!-- 
641                 now build the jalview.binding package with the old schema set
642                 -->
643   <delete>
644     <fileset dir="${sourceDir}/jalview/binding/">
645       <include name="**" />
646     </fileset>
647   </delete>
648   <castor-srcgen file="${schemaDir}/vamsasJvV1.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
649   <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
650   <castor-srcgen file="${schemaDir}/jalviewJvV1.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
651 </target>
652 <target name="sourcedist" description="create jalview source distribution" depends="init">
653   <delete file="${source.dist.name}" />
654   <tar destfile="${source.dist.name}" compression="gzip">
655     <tarfileset dir="./" prefix="jalview" preserveLeadingSlashes="true">
656       <include name="LICENSE" />
657       <include name="README" />
658       <include name="build.xml" />
659       <include name="jalview-jalopy.xml" />
660       <include name="JalviewApplet.jpx" />
661       <include name="JalviewX.jpx" />
662       <include name="nbbuild.xml"/>
663       <include name="nbproject/genfiles.properties"/>
664       <include name="nbproject/project.properties"/>
665       <include name="nbproject/project.xml"/>
666       <include name="${sourceDir}/*.java" />
667       <include name="${sourceDir}/**/*.java" />
668       <include name="${sourceDir}/**/*.cdr" />
669       <include name="${libDir}/**/*" />
670       <include name="${resourceDir}/**/*" />
671       <include name="${helpDir}/**/*" />
672       <include name="appletlib/${jmolJar}" />
673       <exclude name="**/*locales" />
674       <exclude name="*locales/**" />
675       <exclude name="utils/InstallAnywhere/**Build.iap_xml" />
676       <exclude name="utils/InstallAnywhere/**Build*/**" />
677       <exclude name="utils/InstallAnywhere/**Build*/**" />
678       <exclude name="utils/InstallAnywhere/**locale*" />
679       <exclude name="utils/InstallAnywhere/**locale*/**" />
680       <include name="${schemaDir}/**/*" />
681       <include name="utils/**/*" />
682       <include name="${docDir}/**/*" />
683       <include name="examples/**/*" />
684     </tarfileset>
685   </tar>
686 </target>
687 <target name="pubapplet" description="installs the jalviewLite applet and dependent jars into an applet examples directory built under ${outputDir}" depends="makeApplet">
688   <copy todir="${packageDir}/examples">
689     <fileset dir="examples">
690       <include name="**/*"/>
691       <include name="javascript/*"/>
692       <include name="jmol/*"/>
693     </fileset>
694     <fileset dir=".">
695       <include name="${jalviewLiteJar}" />
696     </fileset>
697     <fileset dir="appletlib">
698       <include name="**/*"/>
699     </fileset>
700   </copy>
701   <jar update="true" index="true" jarfile="${packageDir}/examples/${jalviewLiteJar}"/>
702   <jar update="true" index="true" jarfile="${packageDir}/examples/${javaJson}"/>
703   <jar update="true" index="true" jarfile="${packageDir}/examples/${jsonSimple}"/>
704   <jar update="true" index="true" jarfile="${packageDir}/examples/${jmolJar}">
705     <manifest>
706       <attribute name="Application-Name" value="Jmol (bundled with JalviewLite)"/>
707       <!--          <attribute name="Permissions" value="sandbox" /> -->
708       <!--<attribute name="Trusted-Lib" value="true" /> -->
709       <attribute name="Codebase" value="${applet.codebase}"/>
710       <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}"/>
711     </manifest>
712   </jar>
713   <signjar sigalg="SHA1WithRSA" storepass="${jalview.keystore.pass}" keypass="${jalview.key.pass}" keystore="${jalview.keystore}" alias="${jalview.key}" lazy="false" verbose="false">
714     <fileset dir="${packageDir}/examples">
715       <include name="*.jar" />
716     </fileset>
717   </signjar>
718   <presetdef name="ap_applet.jar">
719     <!-- build a signed applet with 'all-permissions' - 
720                           Needs 'param name="permissions' value="all-permissions"' in applet tag
721                           JalviewLite+JmolApplet linked sequence/structure fails
722                           Mixed code warnings are raised
723                           -->
724     <jar update="true" index="true">
725       <manifest>
726         <attribute name="Application-Name" value="JalviewLite" />
727         <attribute name="Permissions" value="all-permissions" />
728         <attribute name="Codebase" value="${applet.codebase}" />
729         <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}" />
730         <attribute name="Application-Library-Allowable-Codebase" value="${applet.codebase}" />
731       </manifest>
732     </jar>
733   </presetdef>
734   <presetdef name="applet.jar">
735     <!-- build signed applet with sandbox permissions -
736                           Needs 'param name="permissions' value="sandbox"' in applet tag
737                          Preserves Pre-Java 1.7_u45 behavior once 'permissions' parameter added to applet tag 
738                         -->
739
740     <jar update="true" index="true">
741       <manifest>
742         <attribute name="Application-Name" value="JalviewLite" />
743         <attribute name="Permissions" value="sandbox" />
744         <attribute name="Codebase" value="${applet.codebase}" />
745         <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}" />
746         <attribute name="Application-Library-Allowable-Codebase" value="${applet.codebase}" />
747       </manifest>
748     </jar>
749   </presetdef>
750   <presetdef name="tl_applet.jar">
751     <!-- build signed applet with trusted library/trusted permissions -
752                                 Needs 'param name="permissions' value="all-permissions"' in applet tag
753                                j1.7_45:
754                                No mixed code warnings raised 
755                                Jmol/JalviewLite sequence/structure example doesn't link structures
756                                Raises dialog asking user to allow page to control applet via LiveConnect javascript
757                                
758                               -->
759
760     <jar update="true" index="true">
761       <manifest>
762         <attribute name="Application-Name" value="JalviewLite" />
763         <attribute name="Permissions" value="all-permissions" />
764         <attribute name="Codebase" value="${applet.codebase}" />
765         <attribute name="Trusted-Only" value="true" />
766         <attribute name="Trusted-Library" value="true" />
767       </manifest>
768     </jar>
769   </presetdef>
770   <presetdef name="to_applet.jar">
771     <!-- not fully test variant (yet) -->
772     <jar update="true" index="true">
773       <manifest>
774         <attribute name="Application-Name" value="JalviewLite" />
775         <attribute name="Permissions" value="all-permissions" />
776         <attribute name="Codebase" value="${applet.codebase}" />
777         <attribute name="Trusted-Only" value="true" />
778       </manifest>
779     </jar>
780   </presetdef>
781   <!-- create differently privileged artefacts -->
782   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/u_${jalviewLiteJar}" />
783   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/u_${jmolJar}" overwrite="true"/>
784   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/u_${javaJson}" overwrite="true"/>
785   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/u_${jsonSimple}" overwrite="true"/>
786   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/ap_${jalviewLiteJar}" />
787   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/ap_${jmolJar}"/>
788   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/ap_${javaJson}"/>
789   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/ap_${jsonSimple}"/>
790   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jalviewLiteJar}" />
791   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jmolJar}" />
792   <ap_applet.jar jarfile="${packageDir}/examples/ap_${javaJson}" />
793   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jsonSimple}" />
794   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/tl_${jalviewLiteJar}" />
795   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/tl_${jmolJar}" />
796   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/tl_${javaJson}" />
797   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/tl_${jsonSimple}" />
798   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jalviewLiteJar}" />
799   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jmolJar}" />
800   <tl_applet.jar jarfile="${packageDir}/examples/tl_${javaJson}" />
801   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jsonSimple}" />
802   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/to_${jalviewLiteJar}" />
803   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/to_${jmolJar}" />
804   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/to_${javaJson}" />
805   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/to_${jsonSimple}" />
806   <to_applet.jar jarfile="${packageDir}/examples/to_${jalviewLiteJar}" />
807   <to_applet.jar jarfile="${packageDir}/examples/to_${jmolJar}" />
808   <to_applet.jar jarfile="${packageDir}/examples/to_${javaJson}" />
809   <to_applet.jar jarfile="${packageDir}/examples/to_${jsonSimple}" />
810   <!-- finally, create manifest for original jars -->
811   <applet.jar jarfile="${packageDir}/examples/${jalviewLiteJar}" />
812   <applet.jar jarfile="${packageDir}/examples/${jmolJar}" />
813   <applet.jar jarfile="${packageDir}/examples/${javaJson}" />
814   <applet.jar jarfile="${packageDir}/examples/${jsonSimple}" />
815
816   <!-- todo - write examples/downloads for alternate versions of the applet -->
817   <signjar storepass="${jalview.keystore.pass}" keypass="${jalview.key.pass}" keystore="${jalview.keystore}" alias="${jalview.key}" lazy="false" verbose="false">
818
819     <fileset dir="${packageDir}/examples">
820       <exclude name="u_*.jar"/>
821       <include name="${jalviewLiteJar}" />
822       <include name="${jmolJar}" />
823       <include name="${javaJson}" />
824       <include name="${jsonSimple}" />
825       <include name="to_${jalviewLiteJar}" />
826       <include name="to_${jmolJar}" />
827       <include name="to_${javaJson}" />
828       <include name="to_${jsonSimple}" />
829       <include name="tl_${jalviewLiteJar}" />
830       <include name="tl_${jmolJar}" />
831       <include name="tl_${javaJson}" />
832       <include name="tl_${jsonSimple}" />
833       <include name="ap_${jalviewLiteJar}" />
834       <include name="ap_${jmolJar}" />
835       <include name="ap_${javaJson}" />
836       <include name="ap_${jsonSimple}" />
837     </fileset>
838   </signjar>
839   <!-- bizarre bug causes JmolApplet to always get signed, even if excluded from above. so copy explicitly -->
840   <copy file="appletlib/${jmolJar}" tofile="${packageDir}/examples/u_${jmolJar}" overwrite="true" />
841         <!-- finally, replace any launchApp servlet tags with a version specification -->
842         <replace value="http://www.jalview.org/services/launchApp?version=${JALVIEW_VERSION}&quot;">
843                 <replacetoken><![CDATA[http://www.jalview.org/services/launchApp"]]></replacetoken>
844                 <fileset dir="${packageDir}/examples">
845                         <include name="**/*.html"/>
846                 </fileset>
847         </replace>
848         <replace value="http://www.jalview.org/services/launchApp?version=${JALVIEW_VERSION}'">
849                 <replacetoken><![CDATA[http://www.jalview.org/services/launchApp']]></replacetoken>
850                 <fileset dir="${packageDir}/examples">
851                         <include name="**/*.html"/>
852                 </fileset>
853         </replace>
854
855 </target>
856 <target name="sourcedoc" description="Create jalview source documentation pages" depends="init">
857   <javadoc destdir="${javadocDir}">
858     <packageset dir="${sourceDir}" includes="jalview/*,MCView/*">
859     </packageset>
860   </javadoc>
861 </target>
862 </project>