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