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