jnlp amsa extension and donotobfuscate property conditional for jalviewLite build
[jalview.git] / build.xml
1 <?xml version="1.0"?>
2 <project name="jalviewX" default="usage" basedir=".">
3         <!-- we use jalopy to format our sources -->
4         <taskdef name="jalopy"
5          classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
6                 <classpath>
7                         <fileset dir="utils/jalopy/lib">
8                                 <include name="*.jar" />
9                         </fileset>
10                 </classpath>
11         </taskdef>
12
13         <target name="help" depends="usage"/>
14         <target name="usage">
15                 <echo message="~~~Jalview Ant build.xml Usage~~~~"/>
16                 <echo message="Targets include:"/>
17                 <echo message="usage - default target, displays this message"/>
18                 <echo message="buildindices - generates JavaHelpSearch from the help files"/>
19                 <echo message="build - compiles all necessary files for Application"/>
20                 <echo message="makedist - compiles and places all necessary jar files into directory dist"/>
21                 <echo message="makefulldist - signs all jar files and builds jnlp file for full distribution"/>
22                 <echo message="              this needs a keystore and key. See docs/building.html for more information."/>
23                 <echo message="compileApplet - compiles all necessary files for Applet"/>
24                 <echo message="makeApplet - compiles, then packages and obfuscates the Applet"/>
25                 <echo message="See docs/building.html and the comments in build file for other targets."/>
26             <echo message="note: compile and makeApplet require the property java118.home to be set to point to a java 1.1.8 jdk."/>
27         </target>
28
29
30         <!-- utils is a class path to additional utilities needed for
31     building docs, jars and webstart stuff -->
32         <!--
33         Userdefined build property defaults
34
35         wsdl.server list (plus namespace mapping info ???)  - also want
36                 ... to make this a dynamically generatable property
37         WebStart Location
38         Build location - provide a temporary root for speed
39         jarsigner keystore and info
40         Jakarta and axis classpath ?
41         Default argument for starting Jalview (if it exists).
42
43 -->
44
45         <target name="init">
46                 <path id="axis.classpath">
47                         <!-->
48                         <fileset dir="/usr/local/axis/lib">
49                                 <include name="**/*.jar" />
50                         </fileset>
51                         <fileset dir="/usr/local/jakarta-tomcat-5/webapps/axis/WEB-INF/lib">
52                                 <include name="**/*.jar"/>
53                                 <include name="*.jar"/>
54                         </fileset> -->
55       </path>
56                 <!-- Jalview Version String displayed by application on startup and used to check for updates -->
57     <property name="JALVIEW_VERSION" value="DEVELOPMENT"/> <!-- 2.4 (VAMSAS)" -->
58                 <!-- Include debugging information in javac true or false -->
59                 <property name="javac.debug" value="true"/>
60                 <!-- Don't change anything below here unless you know what you are doing! -->
61                 <!-- Url path for WebStart in JNLP file -->
62                 <property name="WebStartLocation" value="http://www.jalview.org/webstart"/>
63                 <!-- build directory configuration -->
64                 <property name="libDir" value="lib"/>
65                 <property name="resourceDir" value="resources"/>
66                 <property name="helpDir" value="help"/>
67                 <property name="docDir" value="doc"/>
68                 <property name="sourceDir" value="src" />
69                 <property name="schemaDir" value="schemas" />
70                 <property name="outputDir" value="classes" />
71                 <property name="packageDir" value="dist" />
72                 <property name="outputJar" value="jalview.jar" />
73           <!-- Jalview Applet JMol Jar Dependency -->
74     <property name="jmolJar" value="Jmol-11.0.2.jar" />
75                 <property name="jalviewLiteJar" value="jalviewApplet.jar"/>
76                 <!-- switch to indicate if we should obfuscate jalviewLite -->
77                 <!--<property name="donotobfuscate" value="true"/> -->
78                                 
79                 <!-- Jalview Web Service Clients - see the comments in 'buildextclients' for details -->
80                 <property name="wsdl.File" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred?wsdl" />
81                 <property name="wsdl.Files" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/vamsas?wsdlFiles" />
82                 <property name="wsdl.MsaWS" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS?wsdl" />
83                 <property name="wsdl.MsaWS2" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS?wsdl" />
84                 <property name="WSInterf" value="MsaWS" />
85                 <property name="wsdl.Namespace" value="vamsas" />
86                 <property name="wsdl.ClientNS" value="ext.vamsas" />
87                 <!-- the class path for building the application -->
88                 <path id="build.classpath">
89                         <fileset dir="utils">
90                                 <include name="*.jar"/>
91                                 <include name="**/*.jar"/>
92                         </fileset>
93                         <fileset dir="${libDir}">
94                                 <include name="*.jar"/>
95                                 <include name="**/*.jar"/>
96                         </fileset>
97                         
98                 </path>
99                 <property name="source.dist.name" value="${basedir}/jalview-src.tar.gz"/>
100                 <!-- The Location of the java 1.1.8 jdk -->
101                 <property name="java118.home" value="C:\Sun\jdk1.1.8" />
102                 <property name="applet.jre.tools" value="${java118.home}/lib/classes.zip"/>
103                 <!-- jre for 1.4 version
104                 <property name="applet.jre.tools" value="${java.home}/lib/rt.jar"/>
105                 -->
106                 <!-- the classpath for building the 1.1 applet -->
107                 <path id="jalviewlite.deps">
108                         <fileset dir="${java118.home}">
109                                 <include name="lib/classes.zip"/>
110                         </fileset>
111                 <pathelement location="lib/${jmolJar}"/>
112           </path>
113         </target>
114
115
116         <taskdef classpath="utils/roxes-ant-tasks-1.2-2004-01-30.jar" resource="com/roxes/tools/ant/taskdefs.properties"/>
117         <target name="buildPropertiesFile" depends="init">
118                 <tstamp prefix="build">
119                         <format property="date" pattern="dd MMMM yyyy"/>
120                 </tstamp>
121                 <properties file="${outputDir}/.build_properties">
122                         <header>
123           ---Jalview Build Details---
124         </header>
125                         <property name="VERSION" value="${JALVIEW_VERSION}"/>
126                         <property name="BUILD_DATE" value="${build.date}"/>
127                 </properties>
128         </target>
129
130
131         <target name="clean" depends="init">
132                 <!-- not efficient yet. -->
133                 <delete dir="${outputDir}"/>
134         </target>
135
136         <target name="distclean" depends="init, clean">
137
138                 <echo message="REMOVING ALL BACKUP/AUTOSAVES!"/>
139                 <delete>
140                         <fileset dir=".">
141                                 <include name="${outputJar}"/>
142                                 <include name="#*#"/>
143                                 <include name="#*.*#"/>
144                                 <include name="**/#*#"/>
145                                 <include name="**/#*.*#"/>
146                                 <include name="*~"/>
147                                 <include name="*.*~"/>
148                                 <include name="**/*~"/>
149                                 <include name="**/*.*~"/>
150                         </fileset>
151                 </delete>
152         </target>
153
154         <target name="prepare" depends="init">
155                 <mkdir dir="${outputDir}"/>
156                 <copy todir="${outputDir}">
157                         <fileset dir=".">
158                                 <include name="${docDir}/**/*.*"/>
159                                 <include name="${helpDir}/**/*.*"/>
160                                 <include name="${libDir}/*.jar"/>
161                         </fileset>
162                         <fileset dir="${resourceDir}">
163                                 <include name="**/*.*"/>
164                         </fileset>
165                 </copy>
166         </target>
167
168         <target name="build" depends="prepare">
169                 <!-- not efficient yet. -->
170                 <javac source="1.4" target="1.4"
171         srcdir ="${sourceDir}"
172         destdir="${outputDir}"
173                                 debug="${javac.debug}"
174       classpathref="build.classpath">
175                         <exclude name="jalview/*applet*"/>
176                         <exclude name="com/stevesoft/**"/>
177                 </javac>
178         </target>
179         <target name="buildindices" depends="init, prepare"
180     unless="help.uptodate">
181                 <java
182       classname="com.sun.java.help.search.Indexer"
183       classpathref="build.classpath"
184       fork="true"
185       dir="${outputDir}/${helpDir}"
186       >
187                         <arg line="html"/>
188                 </java>
189         </target>
190
191         <target name="makefulldist" depends="makedist">
192                 <!-- the default keystore details might need to be edited here -->
193                 <signjar
194       storepass="alignmentisfun"
195       keypass="alignmentisfun"
196       keystore="keys/.keystore"
197       alias="jalview"
198       lazy="false"
199       verbose="false"
200       >
201
202                         <fileset dir="${packageDir}">
203                                 <include name="*.jar"/>
204                         </fileset>
205                 </signjar>
206                 <taskdef classpathref="build.classpath" resource="com/roxes/tools/ant/taskdefs.properties"/>
207
208                 <!--    codebase="http://www.jalview.org/jalview/webstart" -->
209                 <!-- href="jalview.jnlp" prevent hard-wired pickup of jnlp in certain javaws versions -->
210                 <jnlp toFile="${packageDir}/jalview.jnlp" 
211       codebase="${WebStartLocation}">
212                         <information>
213                                 <title>Jalview</title>
214                                 <vendor>The Barton Group</vendor>
215                                 <homepage href="http://www.jalview.org"/>
216                                 <description>Jalview Multiple Alignment Editor</description>
217                                 <description kind="short">Jalview</description>
218                                 <icon href="logo_big.gif"/>
219                                 <offline_allowed/>
220                                 <!--
221         <association mime-type="application-x/ext-file" extensions="fa"/>
222         <association mime-type="application-x/ext-file" extensions="fasta"/>
223         <association mime-type="application-x/ext-file" extensions="fastq"/>
224         <association mime-type="application-x/ext-file" extensions="blc"/>
225         <association mime-type="application-x/ext-file" extensions="msf"/>
226         <association mime-type="application-x/ext-file" extensions="pfam"/>
227         <association mime-type="application-x/ext-file" extensions="aln"/>
228         <association mime-type="application-x/ext-file" extensions="pir"/>
229         <association mime-type="application-x/ext-file" extensions="amsa"/>
230         -->
231                         </information>
232                         <resources>
233                                 <j2se version="1.4+"/>
234                                 <fileset dir="${packageDir}">
235                                         <include name="jalview.jar"/>
236                                 </fileset>
237                                 <fileset dir="${packageDir}">
238                                         <include name="*.jar"/>
239                                         <exclude name="jalview.jar"/>
240                                 </fileset>
241                                 <property name="jalview.version" value="${JALVIEW_VERSION}"/>
242                         </resources>
243                         <application_desc main_class="jalview.bin.Jalview">
244                         </application_desc>
245                         <security>
246                                 <all_permissions/>
247                         </security>
248                 </jnlp>
249         </target>
250         <target name="runenv" depends="init">
251                 <path id="run.classpath">
252                         <pathelement location="${outputDir}"/>
253                         <fileset dir="${outputDir}">
254                                 <include name="${libDir}/*.jar"/>
255                         </fileset>
256                 </path>
257                 <pathconvert targetos="unix" refid="run.classpath" property="run.classpath"/>
258
259                 <echo>java -classpath ${run.classpath} jalview.bin.Jalview
260       </echo>
261         </target>
262
263         <target name="buildextclients" depends="init">
264                 <input message="Building external client source from WSDLs - Do you really want to do this ? (Yy/Nn)"
265       validargs="Y,y,n,N" defaultvalue="N"
266       addproperty="doextbuild.response"/>
267                 <condition property="dontextbuild">
268                         <equals arg1="n" arg2="${doextbuild.response}"/>
269                 </condition>
270                 <condition property="dontextbuild">
271                         <equals arg1="N" arg2="${doextbuild.response}"/>
272                 </condition>
273                 <fail if="dontextbuild">
274         Build External Client Code process aborted by user. Jalview source is unchanged.
275       </fail>
276                 <!-- Currently, this doesn't happen automatically.
277      1. Run WSDL2Java as below, which generates an ext.vamsas +
278      vamsas.<datapackages> fileset.
279      2. refactor ext.vamsas.SpecificserviceWS* to
280      ext.vamsas.ServiceclassWS* that implements the ServiceclassWSI interface.
281      3. Update the jalview.ws.*WServices classes to reflect the
282      interface type, and all locations of this wsdl type that Jalview
283      might be using.
284
285 -->
286                 <path id="axisbuild">
287                         <path refid="build.classpath"/>
288                 </path>
289                 <taskdef resource="axis-tasks.properties" classpathref="axisbuild"/>
290                 <move todir="./bak">
291                         <fileset dir="${sourceDir}" id="client">
292                                 <include name="${wsdl.ClientNS}/*.*"/>
293                         </fileset>
294                 </move>
295
296                 <axis-wsdl2java
297       output="${sourceDir}"
298       verbose="true"
299       url="${wsdl.MsaWS2}"
300       serverside="false"
301       deployscope="Request"
302       debug="false"
303       helpergen="true"
304       all="true"
305       >
306                         <mappingSet>
307                                 <mapping
308         namespace="${wsdl.Namespace}"
309         package="${wsdl.ClientNS}"
310         />
311                                 <mapping namespace="http://dataTypes.vamsas"
312         package="${wsdl.ClientNS}"/>
313                         </mappingSet>
314                 </axis-wsdl2java>
315         </target>
316
317         <target name="makedist" depends="build, buildPropertiesFile, buildindices">
318                 <!-- make the package jar -->
319                 <mkdir dir="${packageDir}"/>
320
321                 <jar destfile="${packageDir}/${outputJar}">
322                         <manifest>
323                                 <attribute name="Main-Class" value="jalview.bin.Jalview"/>
324                         </manifest>
325                         <fileset dir="${outputDir}/">
326                                 <exclude name="cache*/**"/>
327                                 <exclude name="*.jar" />
328                                 <exclude name="*.jar.*" />
329                                 <exclude name="**/*.jar" />
330                                 <exclude name="**/*.jar.*" />
331                         </fileset>
332                 </jar>
333
334                 <copy toDir="${packageDir}" flatten="true">
335                         <fileset dir="${outputDir}">
336                                 <include name="*.jar"/>
337                                 <include name="**/*.jar"/>
338                         </fileset>
339                 </copy>
340         </target>
341
342
343         <!-- jalopy code reformatter -->
344         <target name="sourcescrub" depends="init,build">
345                 <jalopy destdir="jsrc" classpathref="run.classpath"
346       convention="jalview-jalopy.xml">
347                         <fileset dir="${sourceDir}">
348                                 <include name="*.java"/>
349                                 <include name="**/*.java"/>
350                                 <include name="**/**/*.java"/>
351                         </fileset>
352                 </jalopy>
353         </target>
354
355
356
357   <!-- Compile, package and obfuscate Jalview Applet -->
358   <target name="makeApplet" depends="obfuscate"/>
359
360   <target name="compileApplet" depends="init,clean">
361     <mkdir dir="${outputDir}"/>
362     <javac source="1.2"
363     target="1.1"
364     srcdir="${sourceDir}" 
365     destdir="${outputDir}"
366     classpath="lib/${jmolJar}"
367        includes="jalview/appletgui/**"
368        excludes="ext/**,MCview/**,org/**,vamsas/**"
369        />
370   </target>
371
372   <target name="packageApplet" depends="compileApplet, buildPropertiesFile">
373   <copy file="${resourceDir}/images/idwidth.gif" toFile="${outputDir}/images/idwidth.gif"/>
374   <copy file="${resourceDir}/images/link.gif" toFile="${outputDir}/images/link.gif"/>
375        <jar destfile="in.jar">
376         <manifest>
377             <attribute name="Main-Class" value="jalview.bin.JalviewLite"/>
378         </manifest>
379         <fileset dir="${outputDir}">
380           <include name="com/**"/>
381           <include name="MCview/**"/>
382           <include name="jalview/**"/>
383           <include name=".build_properties"/>
384           <include name="images/idwidth.gif"/>
385           <include name="images/link.gif"/>
386         </fileset>
387       </jar>
388   </target>
389   <target name="obfuscate" depends="-obfuscatefake,-obfuscatereally" description="construct the final jalviewLite applet jar with or without obfuscation">
390   </target>
391         <target name="-obfuscatefake" depends="packageApplet" if="donotobfuscate">    
392         <copy file="in.jar" tofile="${jalviewLiteJar}" />       
393     <delete file="in.jar"/>
394   </target>
395         <target name="-obfuscatereally" unless="donotobfuscate">
396     
397         <path id="obfuscateDeps.path">
398     <pathelement location="${applet.jre.tools}"/>
399     <pathelement location="lib/${jmolJar}"/>
400     </path>
401     <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard.jar" />
402         
403     <proguard>
404       <injar file="in.jar"/>
405       <outjar file="${jalviewLiteJar}"/>
406       <libraryjar refid="obfuscateDeps.path"/>
407       <keep access="public" type="class"
408       name="jalview.bin.JalviewLite">
409         <field access="public"/>
410         <method access="public"/>
411         <constructor access="public"/>
412       </keep>
413 <!--      -libraryjars "${obfuscateDeps}"
414       -injars      in.jar
415       -outjars     jalviewApplet.jar
416       -keep public class jalview.bin.JalviewLite
417        { public * ; } -->
418       </proguard>
419     <delete file="in.jar"/>
420   </target>
421
422         <target name="castorbinding" depends="init" description="Generate Java bindings to supported Jalview XML models.">
423                 <taskdef name="castor-srcgen"
424                           classname="org.castor.anttask.CastorCodeGenTask"
425                       classpathref="build.classpath" />
426                 <delete>
427                         <fileset dir="${sourceDir}/jalview/schemabinding/version2">
428                                 <include name="*.java"/>
429                                 <include name="descriptors/*.java"/>
430                         </fileset>
431                 </delete>
432                 <castor-srcgen file="${schemaDir}/vamsas.xsd"
433                               todir="${sourceDir}"
434                               package="jalview.schemabinding.version2"
435                               warnings="false" 
436                                         nodesc="false"
437                                                 verbose="true"
438                                                 properties="${schemaDir}/jalview.properties"
439                 />
440                 <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd"
441                               todir="${sourceDir}"
442                               package="jalview.schemabinding.version2"
443                               warnings="false" 
444                                         nodesc="false"
445                                                 verbose="true"
446                                                 properties="${schemaDir}/jalview.properties"
447                 />
448                 <castor-srcgen file="${schemaDir}/jalview.xsd"
449                               todir="${sourceDir}"
450                               package="jalview.schemabinding.version2"
451                               warnings="false" 
452                                           nodesc="false"
453                                                 verbose="true"
454                                                 properties="${schemaDir}/jalview.properties"
455                         
456                 />
457                 <!-- 
458                 now build the jalview.binding package with the old schema set
459                 -->
460                 <delete>
461                         <fileset dir="${sourceDir}/jalview/binding/">
462                                 <include name="**"/>
463                         </fileset>
464                 </delete>
465                 <castor-srcgen file="${schemaDir}/vamsasJvV1.xsd"
466                               todir="${sourceDir}"
467                               package="jalview.binding"
468                               warnings="false" 
469                                         nodesc="true"
470                                                 verbose="true"
471                                                 properties="${schemaDir}/jalview.nodesc.properties"
472                 /> 
473                 <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd"
474                               todir="${sourceDir}"
475                               package="jalview.binding"
476                               warnings="false" 
477                                         nodesc="true"
478                                                 verbose="true"
479                                                 properties="${schemaDir}/jalview.nodesc.properties"
480                 />
481                 <castor-srcgen file="${schemaDir}/jalviewJvV1.xsd"
482                               todir="${sourceDir}"
483                               package="jalview.binding"
484                               warnings="false" 
485                                           nodesc="true"
486                                                 verbose="true"
487                                                 properties="${schemaDir}/jalview.nodesc.properties"
488         />
489         </target>
490         <target name="sourcedist" description="create jalview source distribution" depends="init">
491                 <delete file="${source.dist.name}"/>
492                 <tar destfile="${source.dist.name}" compression="gzip">
493                         <tarfileset dir="./" prefix="jalview" preserveLeadingSlashes="true">
494                                 <include name="LICENSE"/>
495                                 <include name="README"/>
496                                 <include name="build.xml"/>
497                                 <include name="jalview-jalopy.xml"/>
498                                 <include name="JalviewApplet.jpx"/>
499                                 <include name="JalviewX.jpx"/>
500                                 <include name="${sourceDir}/*.java"/>
501                                 <include name="${sourceDir}/**/*.java"/>
502                                 <include name="${sourceDir}/**/*.cdr"/>
503                                 <include name="${libDir}/**/*"/>                                                
504                                 <include name="${resourceDir}/**/*"/>                                           
505                                 <include name="${helpDir}/**/*"/>                                               
506                                 <include name="utils/**/*"/>                                            
507                                 <include name="${schemaDir}/**/*"/>                                             
508                                 <include name="${docDir}/**/*"/>                                                
509                         </tarfileset>
510                 </tar>
511         </target>
512 </project>