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