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