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