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