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