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