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