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