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