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