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