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