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