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