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