JAL-1994 Removed redistributed plugin.jar from applet build path
[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           <fileset dir="${packageDir}">
425             <include name="jalview.jar" />
426           </fileset>
427           <fileset dir="${packageDir}">
428             <include name="*.jar" />
429             <include name="*_*.jar" />
430             <exclude name="jalview.jar" />
431             <exclude name="*jnilib.jar" />
432           </fileset>
433           <property name="jalview.version" value="${JALVIEW_VERSION}" />
434         </resources>
435         <resources os="Mac OS X">
436           <fileset dir="${packageDir}">
437             <include name="*quaqua*.jnilib.jar" />
438           </fileset>
439         </resources>
440
441         <application_desc main_class="jalview.bin.Jalview">
442         </application_desc>
443         <security>
444           <all_permissions />
445         </security>
446       </jnlp>
447     </presetdef>
448
449     <jnlpf toFile="${jnlpFile}" />
450
451   </target>
452
453   <target name="-dofakejnlpfileassoc" depends="-generatejnlpf" if="nojnlpfileassocs">
454     <echo message="Not adding JNLP File Associations" />
455   </target>
456
457   <target name="-dojnlpfileassoc" depends="-generatejnlpf" unless="nojnlpfileassocs">
458     <replace file="${jnlpFile}">
459       <replacetoken>
460         <![CDATA[</information>]]></replacetoken>
461       <replacevalue>
462         <![CDATA[
463           <association mime-type="application-x/ext-file" extensions="fa" />
464         <association mime-type="application-x/ext-file" extensions="fasta" />
465         <association mime-type="application-x/ext-file" extensions="mfa" />
466         <association mime-type="application-x/ext-file" extensions="fastq" />
467         <association mime-type="application-x/ext-file" extensions="blc" />
468         <association mime-type="application-x/ext-file" extensions="msf" />
469         <association mime-type="application-x/ext-file" extensions="pfam" />
470         <association mime-type="application-x/ext-file" extensions="aln"/>
471         <association mime-type="application-x/ext-file" extensions="pir"/>
472         <association mime-type="application-x/ext-file" extensions="amsa"/>
473         <association mime-type="application-x/ext-file" extensions="stk"/>
474         <association mime-type="application-x/ext-file" extensions="jvp"/>
475       </information>]]></replacevalue>
476   </replace>
477   <echo message="Added file associations to JNLP file" />
478 </target>
479 <target name="writejnlpf" depends="-dojnlpfileassoc,-dofakejnlpfileassoc">
480 </target>
481
482 <target name="buildextclients" depends="init">
483   <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" />
484   <condition property="dontextbuild">
485     <equals arg1="n" arg2="${doextbuild.response}" />
486   </condition>
487   <condition property="dontextbuild">
488     <equals arg1="N" arg2="${doextbuild.response}" />
489   </condition>
490   <fail if="dontextbuild">
491         Build External Client Code process aborted by user. Jalview source is unchanged.
492       </fail>
493   <!-- Currently, this doesn't happen automatically.
494      1. Run WSDL2Java as below, which generates an ext.vamsas +
495      vamsas.<datapackages> fileset.
496      2. refactor ext.vamsas.SpecificserviceWS* to
497      ext.vamsas.ServiceclassWS* that implements the ServiceclassWSI interface.
498      3. Update the jalview.ws.*WServices classes to reflect the
499      interface type, and all locations of this wsdl type that Jalview
500      might be using.
501
502 -->
503   <path id="axisbuild">
504     <path refid="build.classpath" />
505   </path>
506   <taskdef resource="axis-tasks.properties" classpathref="axisbuild" />
507   <move todir="./bak">
508     <fileset dir="${sourceDir}" id="client">
509       <include name="${wsdl.ClientNS}/*.*" />
510     </fileset>
511   </move>
512
513   <axis-wsdl2java output="${sourceDir}" verbose="true" url="${wsdl.MsaWS2}" serverside="false" deployscope="Request" debug="false" helpergen="true" all="true">
514     <mappingSet>
515       <mapping namespace="${wsdl.Namespace}" package="${wsdl.ClientNS}" />
516       <mapping namespace="http://dataTypes.vamsas" package="${wsdl.ClientNS}" />
517     </mappingSet>
518   </axis-wsdl2java>
519 </target>
520
521 <target name="makedist" depends="build, buildPropertiesFile, buildindices">
522   <!-- make the package jar if not already existing -->
523   <mkdir dir="${packageDir}" />
524   <!-- clean dir if it already existed -->
525   <delete>
526     <fileset dir="${packageDir}">
527       <include name="*.jar" />
528     </fileset>
529   </delete>
530   <jar destfile="${packageDir}/${outputJar}" index="true">
531     <manifest>
532       <attribute name="Main-Class" value="jalview.bin.Jalview" />
533       <attribute name="Permissions" value="all-permissions" />
534       <attribute name="Application-Name" value="Jalview Desktop" />
535       <attribute name="Codebase" value="${application.codebase}" />
536     </manifest>
537     <fileset dir="${outputDir}/">
538       <exclude name="cache*/**" />
539       <exclude name="*.jar" />
540       <exclude name="*.jar.*" />
541       <exclude name="**/*.jar" />
542       <exclude name="**/*.jar.*" />
543     </fileset>
544   </jar>
545
546   <copy toDir="${packageDir}" flatten="true">
547     <fileset dir="${outputDir}">
548       <include name="*.jar" />
549       <include name="**/*.jar" />
550     </fileset>
551   </copy>
552 </target>
553
554
555 <!-- jalopy code reformatter -->
556 <target name="sourcescrub" depends="init,build">
557   <jalopy destdir="jsrc" classpathref="run.classpath" convention="jalview-jalopy.xml">
558     <fileset dir="${sourceDir}">
559       <include name="*.java" />
560       <include name="**/*.java" />
561       <include name="**/**/*.java" />
562     </fileset>
563   </jalopy>
564 </target>
565
566
567
568 <!-- Compile, package and obfuscate Jalview Applet -->
569 <target name="makeApplet" depends="obfuscate" description="assemble the final jalviewLite applet jar with or without obfuscation" />
570
571 <target name="compileApplet" depends="init,clean">
572   <mkdir dir="${outputDir}" />
573   <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" />
574 </target>
575
576 <target name="packageApplet" depends="compileApplet, buildPropertiesFile">
577   <copy file="${resourceDir}/images/idwidth.gif" toFile="${outputDir}/images/idwidth.gif" />
578   <copy file="${resourceDir}/images/link.gif" toFile="${outputDir}/images/link.gif" />
579   <copy todir="${outputDir}/lang">
580     <fileset dir="${resourceDir}/lang">
581       <include name="**.*" />
582     </fileset>
583   </copy>
584   <jar destfile="in.jar" index="true">
585     <manifest>
586       <attribute name="Main-Class" value="jalview.bin.JalviewLite" />
587       <attribute name="Application-Name" value="JalviewLite" />
588       <attribute name="Codebase" value="${applet.codebase}" />
589     </manifest>
590     <fileset dir="${outputDir}">
591       <include name="com/**" />
592       <include name="MCview/**" />
593       <include name="jalview/**" />
594       <include name=".build_properties" />
595       <include name="images/idwidth.gif" />
596       <include name="images/link.gif" />
597       <include name="lang/**" />
598     </fileset>
599   </jar>
600 </target>
601 <target name="obfuscate" depends="-obfuscatefake,-obfuscatereally">
602 </target>
603 <target name="-obfuscatefake" depends="packageApplet" if="donotobfuscate">
604   <copy file="in.jar" tofile="${jalviewLiteJar}" overwrite="true" />
605   <delete file="in.jar" />
606 </target>
607 <target name="-obfuscatereally" unless="donotobfuscate">
608
609   <path id="obfuscateDeps.path">
610     <pathelement location="${applet.jre.tools}" />
611     <pathelement location="appletlib/${jmolJar}" />
612     <pathelement location="lib/${varnaJar}" />
613     <pathelement location="appletlib/${jsoup}" />
614     <pathelement location="appletlib/${jsonSimple}" />
615     <pathelement location="appletlib/${javaJson}" />
616         <fileset dir="${java.home}/lib">
617         <include name="plugin.jar" />
618     </fileset>
619   </path>
620   <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard.jar" />
621
622   <proguard verbose="true" >
623     <injar file="in.jar" />    
624     <outjar file="${jalviewLiteJar}" />    
625     <libraryjar refid="obfuscateDeps.path" />    
626     <dontwarn />
627     <keep access="public" type="class" name="jalview.bin.JalviewLite">
628       <field access="public" />
629       <method access="public" />
630       <constructor access="public" />
631     </keep>
632     <keep access="public" type="class" name="jalview.appletgui.AlignFrame">
633       <field access="public" />
634       <method access="public" />
635       <constructor access="public" />
636     </keep>
637
638     <keep name="jalview.json.binding**">
639       <constructor/>
640       <method name="*"/>
641     </keep>
642    
643     <keep access="public" type="class" name="MCview.PDBfile">
644       <field access="public" />
645       <method access="public" />
646       <constructor access="public" />
647     </keep>
648
649     <keep access="public" type="class" name="jalview.ws.jws1.Annotate3D">
650       <field access="public" />
651       <method access="public" />
652       <constructor access="public" />
653     </keep>
654     
655     <keep access="public" type="class" name="jalview.ext.jmol.JmolParser">
656       <field access="public" />
657       <method access="public" />
658       <constructor access="public" />
659     </keep>
660     
661     
662     <!--      -libraryjars "${obfuscateDeps}"
663       -injars      in.jar
664       -outjars     jalviewApplet.jar
665       -keep public class jalview.bin.JalviewLite
666        { public * ; } -->
667   </proguard>
668   <delete file="in.jar" />
669 </target>
670
671 <target name="castorbinding" depends="init" description="Generate Java bindings to supported Jalview XML models.">
672   <taskdef name="castor-srcgen" classname="org.castor.anttask.CastorCodeGenTask" classpathref="build.classpath" />
673   <delete>
674     <fileset dir="${sourceDir}/jalview/schemabinding/version2">
675       <include name="*.java" />
676       <include name="descriptors/*.java" />
677     </fileset>
678   </delete>
679   <castor-srcgen file="${schemaDir}/vamsas.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
680   <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
681   <castor-srcgen file="${schemaDir}/JalviewWsParamSet.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
682   <castor-srcgen file="${schemaDir}/jalview.xsd" todir="${sourceDir}" package="jalview.schemabinding.version2" warnings="false" nodesc="false" verbose="true" properties="${schemaDir}/jalview.properties" />
683   <!-- 
684                 now build the jalview.binding package with the old schema set
685                 -->
686   <delete>
687     <fileset dir="${sourceDir}/jalview/binding/">
688       <include name="**" />
689     </fileset>
690   </delete>
691   <castor-srcgen file="${schemaDir}/vamsasJvV1.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
692   <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
693   <castor-srcgen file="${schemaDir}/jalviewJvV1.xsd" todir="${sourceDir}" package="jalview.binding" warnings="false" nodesc="true" verbose="true" properties="${schemaDir}/jalview.nodesc.properties" />
694 </target>
695 <target name="sourcedist" description="create jalview source distribution" depends="init">
696   <delete file="${source.dist.name}" />
697   <tar destfile="${source.dist.name}" compression="gzip">
698     <tarfileset dir="./" prefix="jalview" preserveLeadingSlashes="true">
699       <include name="LICENSE" />
700       <include name="README" />
701       <include name="build.xml" />
702       <include name="jalview-jalopy.xml" />
703       <include name="JalviewApplet.jpx" />
704       <include name="JalviewX.jpx" />
705       <include name="nbbuild.xml" />
706       <include name="nbproject/genfiles.properties" />
707       <include name="nbproject/project.properties" />
708       <include name="nbproject/project.xml" />
709       <include name="${sourceDir}/*.java" />
710       <include name="${sourceDir}/**/*.java" />
711       <include name="${sourceDir}/**/*.cdr" />
712       <include name="${libDir}/**/*" />
713       <include name="${resourceDir}/**/*" />
714       <include name="${helpDir}/**/*" />
715       <include name="appletlib/${jmolJar}" />
716       <include name="appletlib/${jsonSimple}" />
717       <include name="appletlib/${javaJson}" />
718       <exclude name="**/*locales" />
719       <exclude name="*locales/**" />
720       <exclude name="utils/InstallAnywhere/**Build.iap_xml" />
721       <exclude name="utils/InstallAnywhere/**Build*/**" />
722       <exclude name="utils/InstallAnywhere/**Build*/**" />
723       <exclude name="utils/InstallAnywhere/**locale*" />
724       <exclude name="utils/InstallAnywhere/**locale*/**" />
725       <include name="${schemaDir}/**/*" />
726       <include name="utils/**/*" />
727       <include name="${docDir}/**/*" />
728       <include name="examples/**/*" />
729     </tarfileset>
730   </tar>
731 </target>
732 <target name="prepubapplet_1" depends="makeApplet">
733   <copy todir="${packageDir}/examples">
734     <fileset dir="examples">
735       <include name="**/*" />
736       <include name="javascript/*" />
737       <include name="jmol/*" />
738     </fileset>
739     <fileset dir=".">
740       <include name="${jalviewLiteJar}" />
741     </fileset>
742     <fileset dir="appletlib">
743       <include name="**/*" />
744     </fileset>
745   </copy>
746   <jar update="true" index="true" jarfile="${packageDir}/examples/${jalviewLiteJar}" />
747   <jar update="true" index="true" jarfile="${packageDir}/examples/${javaJson}" />
748   <jar update="true" index="true" jarfile="${packageDir}/examples/${jsonSimple}" />
749   <jar update="true" index="true" jarfile="${packageDir}/examples/${jmolJar}">
750     <manifest>
751       <attribute name="Application-Name" value="Jmol (bundled with JalviewLite)" />
752       <!--          <attribute name="Permissions" value="sandbox" /> -->
753       <!--<attribute name="Trusted-Lib" value="true" /> -->
754       <attribute name="Codebase" value="${applet.codebase}" />
755       <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}" />
756     </manifest>
757   </jar>
758
759   <presetdef name="ap_applet.jar">
760     <!-- build a signed applet with 'all-permissions' - 
761                           Needs 'param name="permissions' value="all-permissions"' in applet tag
762                           JalviewLite+JmolApplet linked sequence/structure fails
763                           Mixed code warnings are raised
764                           -->
765     <jar update="true" index="true">
766       <manifest>
767         <attribute name="Application-Name" value="JalviewLite" />
768         <attribute name="Permissions" value="all-permissions" />
769         <attribute name="Codebase" value="${applet.codebase}" />
770         <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}" />
771         <attribute name="Application-Library-Allowable-Codebase" value="${applet.codebase}" />
772       </manifest>
773     </jar>
774   </presetdef>
775   <presetdef name="applet.jar">
776     <!-- build signed applet with sandbox permissions -
777                           Needs 'param name="permissions' value="sandbox"' in applet tag
778                          Preserves Pre-Java 1.7_u45 behavior once 'permissions' parameter added to applet tag 
779                         -->
780
781     <jar update="true" index="true">
782       <manifest>
783         <attribute name="Application-Name" value="JalviewLite" />
784         <attribute name="Permissions" value="sandbox" />
785         <attribute name="Codebase" value="${applet.codebase}" />
786         <attribute name="Caller-Allowable-Codebase" value="${applet.caller-codebase}" />
787         <attribute name="Application-Library-Allowable-Codebase" value="${applet.codebase}" />
788       </manifest>
789     </jar>
790   </presetdef>
791   <presetdef name="tl_applet.jar">
792     <!-- build signed applet with trusted library/trusted permissions -
793                                 Needs 'param name="permissions' value="all-permissions"' in applet tag
794                                j1.7_45:
795                                No mixed code warnings raised 
796                                Jmol/JalviewLite sequence/structure example doesn't link structures
797                                Raises dialog asking user to allow page to control applet via LiveConnect javascript
798                                
799                               -->
800
801     <jar update="true" index="true">
802       <manifest>
803         <attribute name="Application-Name" value="JalviewLite" />
804         <attribute name="Permissions" value="all-permissions" />
805         <attribute name="Codebase" value="${applet.codebase}" />
806         <attribute name="Trusted-Only" value="true" />
807         <attribute name="Trusted-Library" value="true" />
808       </manifest>
809     </jar>
810   </presetdef>
811   <presetdef name="to_applet.jar">
812     <!-- not fully test variant (yet) -->
813     <jar update="true" index="true">
814       <manifest>
815         <attribute name="Application-Name" value="JalviewLite" />
816         <attribute name="Permissions" value="all-permissions" />
817         <attribute name="Codebase" value="${applet.codebase}" />
818         <attribute name="Trusted-Only" value="true" />
819       </manifest>
820     </jar>
821   </presetdef>
822   <!-- create differently privileged artefacts -->
823   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/u_${jalviewLiteJar}" />
824   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/u_${jmolJar}" overwrite="true" />
825   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/u_${javaJson}" overwrite="true" />
826   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/u_${jsonSimple}" overwrite="true" />
827   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/ap_${jalviewLiteJar}" />
828   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/ap_${jmolJar}" />
829   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/ap_${javaJson}" />
830   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/ap_${jsonSimple}" />
831   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jalviewLiteJar}" />
832   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jmolJar}" />
833   <ap_applet.jar jarfile="${packageDir}/examples/ap_${javaJson}" />
834   <ap_applet.jar jarfile="${packageDir}/examples/ap_${jsonSimple}" />
835   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/tl_${jalviewLiteJar}" />
836   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/tl_${jmolJar}" />
837   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/tl_${javaJson}" />
838   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/tl_${jsonSimple}" />
839   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jalviewLiteJar}" />
840   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jmolJar}" />
841   <tl_applet.jar jarfile="${packageDir}/examples/tl_${javaJson}" />
842   <tl_applet.jar jarfile="${packageDir}/examples/tl_${jsonSimple}" />
843   <copy file="${packageDir}/examples/${jalviewLiteJar}" tofile="${packageDir}/examples/to_${jalviewLiteJar}" />
844   <copy file="${packageDir}/examples/${jmolJar}" tofile="${packageDir}/examples/to_${jmolJar}" />
845   <copy file="${packageDir}/examples/${javaJson}" tofile="${packageDir}/examples/to_${javaJson}" />
846   <copy file="${packageDir}/examples/${jsonSimple}" tofile="${packageDir}/examples/to_${jsonSimple}" />
847   <to_applet.jar jarfile="${packageDir}/examples/to_${jalviewLiteJar}" />
848   <to_applet.jar jarfile="${packageDir}/examples/to_${jmolJar}" />
849   <to_applet.jar jarfile="${packageDir}/examples/to_${javaJson}" />
850   <to_applet.jar jarfile="${packageDir}/examples/to_${jsonSimple}" />
851   <!-- finally, create manifest for original jars -->
852   <applet.jar jarfile="${packageDir}/examples/${jalviewLiteJar}" />
853   <applet.jar jarfile="${packageDir}/examples/${jmolJar}" />
854   <applet.jar jarfile="${packageDir}/examples/${javaJson}" />
855   <applet.jar jarfile="${packageDir}/examples/${jsonSimple}" />
856
857   <!-- todo - write examples/downloads for alternate versions of the applet 
858     probably don't need to do this now since we don't have alternate versions anymore !-->
859 </target>
860 <target name="-signapplet" depends="prepubapplet_1">
861   <fileset id="signappletjarset" dir="${packageDir}/examples">
862     <exclude name="u_*.jar" />
863     <include name="${jalviewLiteJar}" />
864     <include name="${jmolJar}" />
865     <include name="${javaJson}" />
866     <include name="${jsonSimple}" />
867     <include name="to_${jalviewLiteJar}" />
868     <include name="to_${jmolJar}" />
869     <include name="to_${javaJson}" />
870     <include name="to_${jsonSimple}" />
871     <include name="tl_${jalviewLiteJar}" />
872     <include name="tl_${jmolJar}" />
873     <include name="tl_${javaJson}" />
874     <include name="tl_${jsonSimple}" />
875     <include name="ap_${jalviewLiteJar}" />
876     <include name="ap_${jmolJar}" />
877     <include name="ap_${javaJson}" />
878     <include name="ap_${jsonSimple}" />
879   </fileset>
880 </target>
881 <target name="-signappletnotsa" unless="timestamp" depends="-signapplet">
882   <signjar storepass="${jalview.keystore.pass}" keypass="${jalview.key.pass}" keystore="${jalview.keystore}" alias="${jalview.key}" lazy="false" verbose="false">
883     <fileset refid="signappletjarset" />
884   </signjar>
885 </target>
886
887 <target name="-signapplettsa" if="timestamp" depends="-signapplet">
888   <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}">
889     <fileset refid="signappletjarset" />
890   </signjar>
891 </target>
892
893 <target name="signApplet" description="internal target to sign applet" depends="-signappletnotsa,-signapplettsa" />
894
895 <target name="pubapplet" description="installs the jalviewLite applet and dependent jars into an applet examples directory built under ${outputDir}" depends="makeApplet, signApplet">
896
897   <!-- bizarre bug causes JmolApplet to always get signed, even if excluded from above. so copy explicitly -->
898   <copy file="appletlib/${jmolJar}" tofile="${packageDir}/examples/u_${jmolJar}" overwrite="true" />
899   <copy file="appletlib/${jsonSimple}" tofile="${packageDir}/examples/u_${jsonSimple}" overwrite="true" />
900   <copy file="appletlib/${javaJson}" tofile="${packageDir}/examples/u_${javaJson}" overwrite="true" />
901   <!-- finally, replace any launchApp servlet tags with a version specification -->
902   <replace value="http://www.jalview.org/services/launchApp?version=${JALVIEW_VERSION}&quot;">
903     <replacetoken>
904       <![CDATA[http://www.jalview.org/services/launchApp"]]>
905     </replacetoken>
906     <fileset dir="${packageDir}/examples">
907       <include name="**/*.html" />
908     </fileset>
909   </replace>
910   <replace value="http://www.jalview.org/services/launchApp?version=${JALVIEW_VERSION}'">
911     <replacetoken>
912       <![CDATA[http://www.jalview.org/services/launchApp']]>
913     </replacetoken>
914     <fileset dir="${packageDir}/examples">
915       <include name="**/*.html" />
916     </fileset>
917   </replace>
918
919 </target>
920 <target name="sourcedoc" description="Create jalview source documentation pages" depends="init">
921   <javadoc destdir="${javadocDir}">
922     <packageset dir="${sourceDir}" includes="jalview/*,MCView/*">
923     </packageset>
924   </javadoc>
925 </target>
926 </project>