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