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