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