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