JAL-2931 patch IA paths for new build box
[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            
463         </replace>
464   </target>
465
466   <target name="-dofakejnlpfileassoc" depends="-generatejnlpf" if="nojnlpfileassocs">
467     <echo message="Not adding JNLP File Associations" />
468   </target>
469
470   <target name="-dojnlpfileassoc" depends="-generatejnlpf" unless="nojnlpfileassocs">
471     <replace file="${jnlpFile}">
472       <replacetoken>
473         <![CDATA[</information>]]></replacetoken>
474       <replacevalue>
475         <![CDATA[
476           <association mime-type="application-x/ext-file" extensions="fa" />
477         <association mime-type="application-x/ext-file" extensions="fasta" />
478         <association mime-type="application-x/ext-file" extensions="mfa" />
479         <association mime-type="application-x/ext-file" extensions="fastq" />
480         <association mime-type="application-x/ext-file" extensions="blc" />
481         <association mime-type="application-x/ext-file" extensions="msf" />
482         <association mime-type="application-x/ext-file" extensions="pfam" />
483         <association mime-type="application-x/ext-file" extensions="aln"/>
484         <association mime-type="application-x/ext-file" extensions="pir"/>
485         <association mime-type="application-x/ext-file" extensions="amsa"/>
486         <association mime-type="application-x/ext-file" extensions="stk"/>
487         <association mime-type="application-x/ext-file" extensions="jvp"/>
488       </information>]]></replacevalue>
489   </replace>
490   <echo message="Added file associations to JNLP file" />
491 </target>
492 <target name="writejnlpf" depends="-dojnlpfileassoc,-dofakejnlpfileassoc">
493 </target>
494
495 <target name="buildextclients" depends="init">
496   <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" />
497   <condition property="dontextbuild">
498     <equals arg1="n" arg2="${doextbuild.response}" />
499   </condition>
500   <condition property="dontextbuild">
501     <equals arg1="N" arg2="${doextbuild.response}" />
502   </condition>
503   <fail if="dontextbuild">
504         Build External Client Code process aborted by user. Jalview source is unchanged.
505       </fail>
506   <!-- Currently, this doesn't happen automatically.
507      1. Run WSDL2Java as below, which generates an ext.vamsas +
508      vamsas.<datapackages> fileset.
509      2. refactor ext.vamsas.SpecificserviceWS* to
510      ext.vamsas.ServiceclassWS* that implements the ServiceclassWSI interface.
511      3. Update the jalview.ws.*WServices classes to reflect the
512      interface type, and all locations of this wsdl type that Jalview
513      might be using.
514
515 -->
516   <path id="axisbuild">
517     <path refid="build.classpath" />
518   </path>
519   <taskdef resource="axis-tasks.properties" classpathref="axisbuild" />
520   <move todir="./bak">
521     <fileset dir="${sourceDir}" id="client">
522       <include name="${wsdl.ClientNS}/*.*" />
523     </fileset>
524   </move>
525
526   <axis-wsdl2java output="${sourceDir}" verbose="true" url="${wsdl.MsaWS2}" serverside="false" deployscope="Request" debug="false" helpergen="true" all="true">
527     <mappingSet>
528       <mapping namespace="${wsdl.Namespace}" package="${wsdl.ClientNS}" />
529       <mapping namespace="http://dataTypes.vamsas" package="${wsdl.ClientNS}" />
530     </mappingSet>
531   </axis-wsdl2java>
532 </target>
533
534 <target name="makedist" depends="build, buildPropertiesFile, linkcheck, buildindices">
535   <!-- make the package jar if not already existing -->
536   <mkdir dir="${packageDir}" />
537   <!-- clean dir if it already existed -->
538   <delete>
539     <fileset dir="${packageDir}">
540       <include name="*.jar" />
541     </fileset>
542   </delete>
543   <jar destfile="${packageDir}/${outputJar}" index="true">
544     <manifest>
545       <attribute name="Main-Class" value="jalview.bin.Jalview" />
546       <attribute name="Permissions" value="all-permissions" />
547       <attribute name="Application-Name" value="Jalview Desktop" />
548       <attribute name="Codebase" value="${application.codebase}" />
549     </manifest>
550     <fileset dir="${outputDir}/">
551       <exclude name="cache*/**" />
552       <exclude name="*.jar" />
553       <exclude name="*.jar.*" />
554       <exclude name="**/*.jar" />
555       <exclude name="**/*.jar.*" />
556     </fileset>
557   </jar>
558
559   <copy toDir="${packageDir}" flatten="true">
560     <fileset dir="${outputDir}">
561       <include name="*.jar" />
562       <include name="**/*.jar" />
563     </fileset>
564   </copy>
565 </target>
566
567
568 <!-- jalopy code reformatter -->
569 <target name="sourcescrub" depends="init,build">
570   <jalopy destdir="jsrc" classpathref="run.classpath" convention="jalview-jalopy.xml">
571     <fileset dir="${sourceDir}">
572       <include name="*.java" />
573       <include name="**/*.java" />
574       <include name="**/**/*.java" />
575     </fileset>
576   </jalopy>
577 </target>
578
579
580
581 <!-- Compile, package and obfuscate Jalview Applet -->
582 <target name="makeApplet" depends="obfuscate" description="assemble the final jalviewLite applet jar with or without obfuscation" />
583
584 <target name="compileApplet" depends="init,clean">
585   <mkdir dir="${outputDir}" />
586   <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/**" />
587 </target>
588
589 <target name="packageApplet" depends="compileApplet, buildPropertiesFile">
590   <copy file="${resourceDir}/images/link.gif" toFile="${outputDir}/images/link.gif" />
591   <copy todir="${outputDir}/lang">
592     <fileset dir="${resourceDir}/lang">
593       <include name="**.*" />
594     </fileset>
595   </copy>
596   <jar destfile="in.jar" index="true">
597     <manifest>
598       <attribute name="Main-Class" value="jalview.bin.JalviewLite" />
599       <attribute name="Application-Name" value="JalviewLite" />
600       <attribute name="Codebase" value="${applet.codebase}" />
601     </manifest>
602     <fileset dir="${outputDir}">
603       <include name="com/**" />
604       <include name="MCview/**" />
605       <include name="jalview/**" />
606       <include name=".build_properties" />
607       <include name="images/link.gif" />
608       <include name="lang/**" />
609     </fileset>
610   </jar>
611 </target>
612 <target name="obfuscate" depends="-obfuscatefake,-obfuscatereally">
613 </target>
614 <target name="-obfuscatefake" depends="packageApplet" if="donotobfuscate">
615   <copy file="in.jar" tofile="${jalviewLiteJar}" overwrite="true" />
616   <delete file="in.jar" />
617 </target>
618 <target name="-obfuscatereally" unless="donotobfuscate">
619
620   <path id="obfuscateDeps.path">
621     <pathelement location="${applet.jre.tools}" />
622     <pathelement location="appletlib/${jmolJar}" />
623     <pathelement location="lib/${varnaJar}" />
624     <pathelement location="appletlib/${jsoup}" />
625     <pathelement location="appletlib/${jsonSimple}" />
626     <pathelement location="appletlib/${javaJson}" />
627     <fileset dir="${java.home}/lib">
628       <include name="plugin.jar" />
629     </fileset>
630   </path>
631   <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard_5.3.3.jar" />
632
633   <proguard verbose="true" >
634     <injar file="in.jar" />
635     <outjar file="${jalviewLiteJar}" />
636     <libraryjar refid="obfuscateDeps.path" />
637     <dontwarn />
638     <keep access="public" type="class" name="jalview.bin.JalviewLite">
639       <field access="public" />
640       <method access="public" />
641       <constructor access="public" />
642     </keep>
643     <keep access="public" type="class" name="jalview.appletgui.AlignFrame">
644       <field access="public" />
645       <method access="public" />
646       <constructor access="public" />
647     </keep>
648
649     <keep name="jalview.json.binding**">
650       <constructor/>
651       <method name="*"/>
652     </keep>
653
654     <keep access="public" type="class" name="MCview.PDBfile">
655       <field access="public" />
656       <method access="public" />
657       <constructor access="public" />
658     </keep>
659
660     <keep access="public" type="class" name="jalview.ws.jws1.Annotate3D">
661       <field access="public" />
662       <method access="public" />
663       <constructor access="public" />
664     </keep>
665
666     <keep access="public" type="class" name="jalview.ext.jmol.JmolParser">
667       <field access="public" />
668       <method access="public" />
669       <constructor access="public" />
670     </keep>
671
672
673     <!--      -libraryjars "${obfuscateDeps}"
674       -injars      in.jar
675       -outjars     jalviewApplet.jar
676       -keep public class jalview.bin.JalviewLite
677        { public * ; } -->
678   </proguard>
679   <delete file="in.jar" />
680 </target>
681
682 <target name="castorbinding" depends="init" description="Generate Java bindings to supported Jalview XML models.">
683   <taskdef name="castor-srcgen" classname="org.castor.anttask.CastorCodeGenTask" classpathref="build.classpath" />
684   <delete>
685     <fileset dir="${sourceDir}/jalview/schemabinding/version2">
686       <include name="*.java" />
687       <include name="descriptors/*.java" />
688     </fileset>
689   </delete>
690   <castor-srcgen file="${schemaDir}/vamsas.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
691   <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
692   <castor-srcgen file="${schemaDir}/JalviewWsParamSet.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
693   <castor-srcgen file="${schemaDir}/jalview.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
694   <!-- 
695                 now build the jalview.binding package with the old schema set
696                 -->
697   <delete>
698     <fileset dir="${sourceDir}/jalview/binding/">
699       <include name="**" />
700     </fileset>
701   </delete>
702   <castor-srcgen file="${schemaDir}/vamsasJvV1.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
703   <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
704   <castor-srcgen file="${schemaDir}/jalviewJvV1.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
705 </target>
706 <target name="sourcedist" description="create jalview source distribution" depends="init">
707   <delete file="${source.dist.name}" />
708   <!-- temporary copy of source to update timestamps -->
709   <copy todir="_sourcedist">
710     <fileset dir=".">
711       <exclude name=".*" />
712       <exclude name="**/.*" />
713       <exclude name="*.class" />
714       <exclude name="**/*.class" />
715       <include name="LICENSE" />
716       <include name="README" />
717       <include name="build.xml" />
718       <include name="jalview-jalopy.xml" />
719       <include name="JalviewApplet.jpx" />
720       <include name="JalviewX.jpx" />
721       <include name="nbbuild.xml" />
722       <include name="nbproject/genfiles.properties" />
723       <include name="nbproject/project.properties" />
724       <include name="nbproject/project.xml" />
725       <include name="${sourceDir}/*.java" />
726       <include name="${sourceDir}/**/*.java" />
727       <include name="${sourceDir}/**/*.cdr" />
728       <include name="${libDir}/**/*" />
729       <include name="${resourceDir}/**/*" />
730       <include name="${helpDir}/**/*" />
731       <include name="appletlib/${jmolJar}" />
732       <include name="appletlib/${jsonSimple}" />
733       <include name="appletlib/${javaJson}" />
734       <exclude name="**/*locales" />
735       <exclude name="*locales/**" />
736       <exclude name="utils/InstallAnywhere/**Build.iap_xml" />
737       <exclude name="utils/InstallAnywhere/**Build*/**" />
738       <exclude name="utils/InstallAnywhere/**Build*/**" />
739       <exclude name="utils/InstallAnywhere/.build*.*/**" />
740       <exclude name="utils/InstallAnywhere/**locale*" />
741       <exclude name="utils/InstallAnywhere/**locale*/**" />
742       <exclude name="utils/InstallAnywhere/**locale*/**" />
743       <include name="${schemaDir}/**/*" />
744       <include name="utils/**/*" />
745       <include name="${docDir}/**/*" />
746       <include name="examples/**/*" />
747     </fileset>
748   </copy>
749
750   <tstamp prefix="build">
751     <format property="year" pattern="yyyy" />
752   </tstamp>
753   <!-- each replacetoken CDATA body must be on one line - 
754        otherwise the pattern doesn't match -->
755   <replace value="${JALVIEW_VERSION}">
756     <replacetoken><![CDATA[$$Version-Rel$$]]></replacetoken>
757     <fileset dir="_sourcedist">
758       <include name="**/*" />
759     </fileset>
760   </replace>
761   <replace dir="_sourcedist" value="${build.year}">
762     <replacetoken><![CDATA[$$Year-Rel$$]]></replacetoken>
763     <fileset dir="_sourcedist">
764       <include name="**/*" />
765     </fileset>
766   </replace>
767
768   <tar destfile="${source.dist.name}" compression="gzip">
769     <tarfileset dir="_sourcedist/" prefix="jalview" preserveLeadingSlashes="true">
770     </tarfileset>
771   </tar>
772
773   <delete dir="_sourcedist" />
774 </target>
775 <target name="prepubapplet_1" depends="makeApplet">
776   <copy todir="${packageDir}/examples">
777     <fileset dir="examples">
778       <include name="**/*" />
779       <include name="javascript/*" />
780       <include name="jmol/*" />
781     </fileset>
782     <fileset dir=".">
783       <include name="${jalviewLiteJar}" />
784     </fileset>
785     <fileset dir="appletlib">
786       <include name="**/*" />
787     </fileset>
788   </copy>
789   <jar update="true" index="true" jarfile="${packageDir}/examples/${jalviewLiteJar}" />
790   <jar update="true" index="true" jarfile="${packageDir}/examples/${javaJson}" />
791   <jar update="true" index="true" jarfile="${packageDir}/examples/${jsonSimple}" />
792   <jar update="true" index="true" jarfile="${packageDir}/examples/${jmolJar}">
793     <manifest>
794       <attribute name="Application-Name" value="Jmol (bundled with JalviewLite)" />
795       <!--          <attribute name="Permissions" value="sandbox" /> -->
796       <!--<attribute name="Trusted-Lib" value="true" /> -->
797       <attribute name="Codebase" value="${applet.codebase}" />
798       <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}" />
799     </manifest>
800   </jar>
801
802   <presetdef name="ap_applet.jar">
803     <!-- build a signed applet with 'all-permissions' - 
804                           Needs 'param name="permissions' value="all-permissions"' in applet tag
805                           JalviewLite+JmolApplet linked sequence/structure fails
806                           Mixed code warnings are raised
807                           -->
808     <jar update="true" index="true">
809       <manifest>
810         <attribute name="Application-Name" value="JalviewLite" />
811         <attribute name="Permissions" value="all-permissions" />
812         <attribute name="Codebase" value="${applet.codebase}" />
813         <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}" />
814         <attribute name="Application-Library-Allowable-Codebase" value="${applet.codebase}" />
815       </manifest>
816     </jar>
817   </presetdef>
818   <presetdef name="applet.jar">
819     <!-- build signed applet with sandbox permissions -
820                           Needs 'param name="permissions' value="sandbox"' in applet tag
821                          Preserves Pre-Java 1.7_u45 behavior once 'permissions' parameter added to applet tag 
822                         -->
823
824     <jar update="true" index="true">
825       <manifest>
826         <attribute name="Application-Name" value="JalviewLite" />
827         <attribute name="Permissions" value="sandbox" />
828         <attribute name="Codebase" value="${applet.codebase}" />
829         <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}" />
830         <attribute name="Application-Library-Allowable-Codebase" value="${applet.codebase}" />
831       </manifest>
832     </jar>
833   </presetdef>
834   <presetdef name="tl_applet.jar">
835     <!-- build signed applet with trusted library/trusted permissions -
836                                 Needs 'param name="permissions' value="all-permissions"' in applet tag
837                                j1.7_45:
838                                No mixed code warnings raised 
839                                Jmol/JalviewLite sequence/structure example doesn't link structures
840                                Raises dialog asking user to allow page to control applet via LiveConnect javascript
841                                
842                               -->
843
844     <jar update="true" index="true">
845       <manifest>
846         <attribute name="Application-Name" value="JalviewLite" />
847         <attribute name="Permissions" value="all-permissions" />
848         <attribute name="Codebase" value="${applet.codebase}" />
849         <attribute name="Trusted-Only" value="true" />
850         <attribute name="Trusted-Library" value="true" />
851       </manifest>
852     </jar>
853   </presetdef>
854   <presetdef name="to_applet.jar">
855     <!-- not fully test variant (yet) -->
856     <jar update="true" index="true">
857       <manifest>
858         <attribute name="Application-Name" value="JalviewLite" />
859         <attribute name="Permissions" value="all-permissions" />
860         <attribute name="Codebase" value="${applet.codebase}" />
861         <attribute name="Trusted-Only" value="true" />
862       </manifest>
863     </jar>
864   </presetdef>
865   <!-- create differently privileged artefacts -->
866   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/u_${jalviewLiteJar}" />
867   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/u_${jmolJar}" overwrite="true" />
868   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/u_${javaJson}" overwrite="true" />
869   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/u_${jsonSimple}" overwrite="true" />
870   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/ap_${jalviewLiteJar}" />
871   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/ap_${jmolJar}" />
872   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/ap_${javaJson}" />
873   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/ap_${jsonSimple}" />
874   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jalviewLiteJar}" />
875   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jmolJar}" />
876   <ap_applet.jar jarfile="${packageDir}/examples/ap_${javaJson}" />
877   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jsonSimple}" />
878   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/tl_${jalviewLiteJar}" />
879   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/tl_${jmolJar}" />
880   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/tl_${javaJson}" />
881   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/tl_${jsonSimple}" />
882   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jalviewLiteJar}" />
883   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jmolJar}" />
884   <tl_applet.jar jarfile="${packageDir}/examples/tl_${javaJson}" />
885   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jsonSimple}" />
886   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/to_${jalviewLiteJar}" />
887   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/to_${jmolJar}" />
888   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/to_${javaJson}" />
889   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/to_${jsonSimple}" />
890   <to_applet.jar jarfile="${packageDir}/examples/to_${jalviewLiteJar}" />
891   <to_applet.jar jarfile="${packageDir}/examples/to_${jmolJar}" />
892   <to_applet.jar jarfile="${packageDir}/examples/to_${javaJson}" />
893   <to_applet.jar jarfile="${packageDir}/examples/to_${jsonSimple}" />
894   <!-- finally, create manifest for original jars -->
895   <applet.jar jarfile="${packageDir}/examples/${jalviewLiteJar}" />
896   <applet.jar jarfile="${packageDir}/examples/${jmolJar}" />
897   <applet.jar jarfile="${packageDir}/examples/${javaJson}" />
898   <applet.jar jarfile="${packageDir}/examples/${jsonSimple}" />
899
900   <!-- todo - write examples/downloads for alternate versions of the applet 
901     probably don't need to do this now since we don't have alternate versions anymore !-->
902 </target>
903 <target name="-signapplet" depends="prepubapplet_1">
904   <fileset id="signappletjarset" dir="${packageDir}/examples">
905     <exclude name="u_*.jar" />
906     <include name="${jalviewLiteJar}" />
907     <include name="${jmolJar}" />
908     <include name="${javaJson}" />
909     <include name="${jsonSimple}" />
910     <include name="to_${jalviewLiteJar}" />
911     <include name="to_${jmolJar}" />
912     <include name="to_${javaJson}" />
913     <include name="to_${jsonSimple}" />
914     <include name="tl_${jalviewLiteJar}" />
915     <include name="tl_${jmolJar}" />
916     <include name="tl_${javaJson}" />
917     <include name="tl_${jsonSimple}" />
918     <include name="ap_${jalviewLiteJar}" />
919     <include name="ap_${jmolJar}" />
920     <include name="ap_${javaJson}" />
921     <include name="ap_${jsonSimple}" />
922   </fileset>
923 </target>
924 <target name="-signappletnotsa" unless="timestamp" depends="-signapplet">
925   <signjar storepass="${jalview.keystore.pass}" keypass="${jalview.key.pass}" keystore="${jalview.keystore}" alias="${jalview.key}" lazy="false" verbose="false">
926     <fileset refid="signappletjarset" />
927   </signjar>
928 </target>
929
930 <target name="-signapplettsa" if="timestamp" depends="-signapplet">
931   <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}">
932     <fileset refid="signappletjarset" />
933   </signjar>
934 </target>
935
936 <target name="signApplet" description="internal target to sign applet" depends="-signappletnotsa,-signapplettsa" />
937
938 <target name="pubapplet" description="installs the jalviewLite applet and dependent jars into an applet examples directory built under ${outputDir}" depends="makeApplet, signApplet">
939
940   <!-- bizarre bug causes JmolApplet to always get signed, even if excluded from above. so copy explicitly -->
941   <copy file="appletlib/${jmolJar}" tofile="${packageDir}/examples/u_${jmolJar}" overwrite="true" />
942   <copy file="appletlib/${jsonSimple}" tofile="${packageDir}/examples/u_${jsonSimple}" overwrite="true" />
943   <copy file="appletlib/${javaJson}" tofile="${packageDir}/examples/u_${javaJson}" overwrite="true" />
944   <!-- finally, replace any launchApp servlet tags with a version specification -->
945   <replace value="http://www.jalview.org/services/launchApp?version=${JALVIEW_VERSION}&quot;">
946     <replacetoken>
947       <![CDATA[http://www.jalview.org/services/launchApp"]]>
948     </replacetoken>
949     <fileset dir="${packageDir}/examples">
950       <include name="**/*.html" />
951     </fileset>
952   </replace>
953   <replace value="http://www.jalview.org/services/launchApp?version=${JALVIEW_VERSION}'">
954     <replacetoken>
955       <![CDATA[http://www.jalview.org/services/launchApp']]>
956     </replacetoken>
957     <fileset dir="${packageDir}/examples">
958       <include name="**/*.html" />
959     </fileset>
960   </replace>
961
962 </target>
963 <target name="sourcedoc" description="Create jalview source documentation pages" depends="init">
964   <javadoc destdir="${javadocDir}">
965     <packageset dir="${sourceDir}" includes="jalview/*,MCView/*">
966     </packageset>
967   </javadoc>
968 </target>
969 <target name="linkcheck" depends="init,prepare">
970   <javac srcdir="utils" destdir="utils" includes="HelpLinksChecker.java"/>
971   <java fork="true" dir="${helpDir}" classpath="utils" classname="HelpLinksChecker" failonerror="true">
972     <arg file="${helpDir}"/>
973     <arg value="-nointernet"/>
974   </java>
975 </target>
976 </project>