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