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