property for including debug info in classes
[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                 <!-- Jalview Web Service Clients - see the comments in 'buildextclients' for details -->
76                 <property name="wsdl.File" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred?wsdl" />
77                 <property name="wsdl.Files" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/vamsas?wsdlFiles" />
78                 <property name="wsdl.MsaWS" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS?wsdl" />
79                 <property name="wsdl.MsaWS2" value="http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS?wsdl" />
80                 <property name="WSInterf" value="MsaWS" />
81                 <property name="wsdl.Namespace" value="vamsas" />
82                 <property name="wsdl.ClientNS" value="ext.vamsas" />
83                 <!-- the class path for building the application -->
84                 <path id="build.classpath">
85                         <fileset dir="utils">
86                                 <include name="*.jar"/>
87                                 <include name="**/*.jar"/>
88                         </fileset>
89                         <fileset dir="${libDir}">
90                                 <include name="*.jar"/>
91                                 <include name="**/*.jar"/>
92                         </fileset>
93                 </path>
94                 <!-- The Location of the java 1.1.8 jdk -->
95                 <property name="java118.home" value="C:\Sun\jdk1.1.8" />
96                 <property name="applet.jre.tools" value="${java118.home}/lib/classes.zip"/>
97                 <!-- jre for 1.4 version
98                 <property name="applet.jre.tools" value="${java.home}/lib/rt.jar"/>
99                 -->
100                 <!-- the classpath for building the 1.1 applet -->
101                 <path id="jalviewlite.deps">
102                         <fileset dir="${java118.home}">
103                                 <include name="lib/classes.zip"/>
104                         </fileset>
105                 <pathelement location="lib/${jmolJar}"/>
106           </path>
107         </target>
108
109
110         <taskdef classpath="utils/roxes-ant-tasks-1.2-2004-01-30.jar" resource="com/roxes/tools/ant/taskdefs.properties"/>
111         <target name="buildPropertiesFile" depends="init">
112                 <tstamp prefix="build">
113                         <format property="date" pattern="dd MMMM yyyy"/>
114                 </tstamp>
115                 <properties file="${outputDir}/.build_properties">
116                         <header>
117           ---Jalview Build Details---
118         </header>
119                         <property name="VERSION" value="${JALVIEW_VERSION}"/>
120                         <property name="BUILD_DATE" value="${build.date}"/>
121                 </properties>
122         </target>
123
124
125         <target name="clean" depends="init">
126                 <!-- not efficient yet. -->
127                 <delete dir="${outputDir}"/>
128         </target>
129
130         <target name="distclean" depends="init, clean">
131
132                 <echo message="REMOVING ALL BACKUP/AUTOSAVES!"/>
133                 <delete>
134                         <fileset dir=".">
135                                 <include name="${outputJar}"/>
136                                 <include name="#*#"/>
137                                 <include name="#*.*#"/>
138                                 <include name="**/#*#"/>
139                                 <include name="**/#*.*#"/>
140                                 <include name="*~"/>
141                                 <include name="*.*~"/>
142                                 <include name="**/*~"/>
143                                 <include name="**/*.*~"/>
144                         </fileset>
145                 </delete>
146         </target>
147
148         <target name="prepare" depends="init">
149                 <mkdir dir="${outputDir}"/>
150                 <copy todir="${outputDir}">
151                         <fileset dir=".">
152                                 <include name="${docDir}/**/*.*"/>
153                                 <include name="${helpDir}/**/*.*"/>
154                                 <include name="${libDir}/*.jar"/>
155                         </fileset>
156                         <fileset dir="${resourceDir}">
157                                 <include name="**/*.*"/>
158                         </fileset>
159                 </copy>
160         </target>
161
162         <target name="build" depends="prepare">
163                 <!-- not efficient yet. -->
164                 <javac source="1.4" target="1.4"
165         srcdir ="${sourceDir}"
166         destdir="${outputDir}"
167                                 debug="${javac.debug}"
168       classpathref="build.classpath">
169                         <exclude name="jalview/*applet*"/>
170                         <exclude name="com/stevesoft/**"/>
171                 </javac>
172         </target>
173         <target name="buildindices" depends="init, prepare"
174     unless="help.uptodate">
175                 <java
176       classname="com.sun.java.help.search.Indexer"
177       classpathref="build.classpath"
178       fork="true"
179       dir="${outputDir}/${helpDir}"
180       >
181                         <arg line="html"/>
182                 </java>
183         </target>
184
185         <target name="makefulldist" depends="makedist">
186                 <!-- the default keystore details might need to be edited here -->
187                 <signjar
188       storepass="alignmentisfun"
189       keypass="alignmentisfun"
190       keystore="keys/.keystore"
191       alias="jalview"
192       lazy="false"
193       verbose="false"
194       >
195
196                         <fileset dir="${packageDir}">
197                                 <include name="*.jar"/>
198                         </fileset>
199                 </signjar>
200                 <taskdef classpathref="build.classpath" resource="com/roxes/tools/ant/taskdefs.properties"/>
201
202                 <!--    codebase="http://www.jalview.org/jalview/webstart" -->
203                 <jnlp toFile="${packageDir}/jalview.jnlp" href="jalview.jnlp"
204       codebase="${WebStartLocation}">
205                         <information>
206                                 <title>Jalview</title>
207                                 <vendor>The Barton Group</vendor>
208                                 <homepage href="http://www.jalview.org"/>
209                                 <description>Jalview Multiple Alignment Editor</description>
210                                 <description kind="short">Jalview</description>
211                                 <icon href="logo_big.gif"/>
212                                 <offline_allowed/>
213                                 <!--
214         <association mime-type="application-x/ext-file" extensions="fa"/>
215         <association mime-type="application-x/ext-file" extensions="fasta"/>
216         <association mime-type="application-x/ext-file" extensions="fastq"/>
217         <association mime-type="application-x/ext-file" extensions="blc"/>
218         <association mime-type="application-x/ext-file" extensions="msf"/>
219         <association mime-type="application-x/ext-file" extensions="pfam"/>
220         <association mime-type="application-x/ext-file" extensions="aln"/>
221         <association mime-type="application-x/ext-file" extensions="pir"/>
222         -->
223                         </information>
224                         <resources>
225                                 <j2se version="1.4+"/>
226                                 <fileset dir="${packageDir}">
227                                         <include name="jalview.jar"/>
228                                 </fileset>
229                                 <fileset dir="${packageDir}">
230                                         <include name="*.jar"/>
231                                         <exclude name="jalview.jar"/>
232                                 </fileset>
233                                 <property name="jalview.version" value="${JALVIEW_VERSION}"/>
234                         </resources>
235                         <application_desc main_class="jalview.bin.Jalview">
236                         </application_desc>
237                         <security>
238                                 <all_permissions/>
239                         </security>
240                 </jnlp>
241         </target>
242         <target name="runenv" depends="init">
243                 <path id="run.classpath">
244                         <pathelement location="${outputDir}"/>
245                         <fileset dir="${outputDir}">
246                                 <include name="${libDir}/*.jar"/>
247                         </fileset>
248                 </path>
249                 <pathconvert targetos="unix" refid="run.classpath" property="run.classpath"/>
250
251                 <echo>java -classpath ${run.classpath} jalview.bin.Jalview
252       </echo>
253         </target>
254
255         <target name="buildextclients" depends="init">
256                 <input message="Building external client source from WSDLs - Do you really want to do this ? (Yy/Nn)"
257       validargs="Y,y,n,N" defaultvalue="N"
258       addproperty="doextbuild.response"/>
259                 <condition property="dontextbuild">
260                         <equals arg1="n" arg2="${doextbuild.response}"/>
261                 </condition>
262                 <condition property="dontextbuild">
263                         <equals arg1="N" arg2="${doextbuild.response}"/>
264                 </condition>
265                 <fail if="dontextbuild">
266         Build External Client Code process aborted by user. Jalview source is unchanged.
267       </fail>
268                 <!-- Currently, this doesn't happen automatically.
269      1. Run WSDL2Java as below, which generates an ext.vamsas +
270      vamsas.<datapackages> fileset.
271      2. refactor ext.vamsas.SpecificserviceWS* to
272      ext.vamsas.ServiceclassWS* that implements the ServiceclassWSI interface.
273      3. Update the jalview.ws.*WServices classes to reflect the
274      interface type, and all locations of this wsdl type that Jalview
275      might be using.
276
277 -->
278                 <path id="axisbuild">
279                         <path refid="build.classpath"/>
280                 </path>
281                 <taskdef resource="axis-tasks.properties" classpathref="axisbuild"/>
282                 <move todir="./bak">
283                         <fileset dir="${sourceDir}" id="client">
284                                 <include name="${wsdl.ClientNS}/*.*"/>
285                         </fileset>
286                 </move>
287
288                 <axis-wsdl2java
289       output="${sourceDir}"
290       verbose="true"
291       url="${wsdl.MsaWS2}"
292       serverside="false"
293       deployscope="Request"
294       debug="false"
295       helpergen="true"
296       all="true"
297       >
298                         <mappingSet>
299                                 <mapping
300         namespace="${wsdl.Namespace}"
301         package="${wsdl.ClientNS}"
302         />
303                                 <mapping namespace="http://dataTypes.vamsas"
304         package="${wsdl.ClientNS}"/>
305                         </mappingSet>
306                 </axis-wsdl2java>
307         </target>
308
309         <target name="makedist" depends="build, buildPropertiesFile, buildindices">
310                 <!-- make the package jar -->
311                 <mkdir dir="${packageDir}"/>
312
313                 <jar destfile="${packageDir}/${outputJar}">
314                         <manifest>
315                                 <attribute name="Main-Class" value="jalview.bin.Jalview"/>
316                         </manifest>
317                         <fileset dir="${outputDir}/">
318                                 <exclude name="cache*/**"/>
319                                 <exclude name="*.jar" />
320                                 <exclude name="*.jar.*" />
321                                 <exclude name="**/*.jar" />
322                                 <exclude name="**/*.jar.*" />
323                         </fileset>
324                 </jar>
325
326                 <copy toDir="${packageDir}" flatten="true">
327                         <fileset dir="${outputDir}">
328                                 <include name="*.jar"/>
329                                 <include name="**/*.jar"/>
330                         </fileset>
331                 </copy>
332         </target>
333
334
335         <!-- jalopy code reformatter -->
336         <target name="sourcescrub" depends="init,build">
337                 <jalopy destdir="jsrc" classpathref="run.classpath"
338       convention="jalview-jalopy.xml">
339                         <fileset dir="${sourceDir}">
340                                 <include name="*.java"/>
341                                 <include name="**/*.java"/>
342                                 <include name="**/**/*.java"/>
343                         </fileset>
344                 </jalopy>
345         </target>
346
347
348
349   <!-- Compile, package and obfuscate Jalview Applet -->
350   <target name="makeApplet" depends="obfuscate"/>
351
352   <target name="compileApplet" depends="init,clean">
353     <mkdir dir="${outputDir}"/>
354     <javac source="1.2"
355     target="1.1"
356     srcdir="${sourceDir}" 
357     destdir="${outputDir}"
358     classpath="lib/${jmolJar}"
359        includes="jalview/appletgui/**"
360        excludes="ext/**,MCview/**,org/**,vamsas/**"
361        />
362   </target>
363
364   <target name="packageApplet" depends="compileApplet, buildPropertiesFile">
365   <copy file="${resourceDir}/images/idwidth.gif" toFile="${outputDir}/images/idwidth.gif"/>
366   <copy file="${resourceDir}/images/link.gif" toFile="${outputDir}/images/link.gif"/>
367        <jar destfile="in.jar">
368         <manifest>
369             <attribute name="Main-Class" value="jalview.bin.JalviewLite"/>
370         </manifest>
371         <fileset dir="${outputDir}">
372           <include name="com/**"/>
373           <include name="MCview/**"/>
374           <include name="jalview/**"/>
375           <include name=".build_properties"/>
376           <include name="images/idwidth.gif"/>
377           <include name="images/link.gif"/>
378         </fileset>
379       </jar>
380   </target>
381
382   <target name="obfuscate" depends="packageApplet">
383     <path id="obfuscateDeps.path">
384     <pathelement location="${applet.jre.tools}"/>
385     <pathelement location="lib/${jmolJar}"/>
386     </path>
387     <taskdef resource="proguard/ant/task.properties" classpath="utils/proguard.jar" />
388     <proguard>
389       <injar file="in.jar"/>
390       <outjar file="jalviewApplet.jar"/>
391       <libraryjar refid="obfuscateDeps.path"/>
392       <keep access="public" type="class"
393       name="jalview.bin.JalviewLite">
394         <field access="public"/>
395         <method access="public"/>
396         <constructor access="public"/>
397       </keep>
398 <!--      -libraryjars "${obfuscateDeps}"
399       -injars      in.jar
400       -outjars     jalviewApplet.jar
401       -keep public class jalview.bin.JalviewLite
402        { public * ; }
403        -->
404     </proguard>
405     <delete file="in.jar"/>
406   </target>
407
408         <target name="castorbinding" depends="init" description="Generate Java bindings to supported Jalview XML models.">
409                 <taskdef name="castor-srcgen"
410                           classname="org.castor.anttask.CastorCodeGenTask"
411                       classpathref="build.classpath" />
412                 <delete>
413                         <fileset dir="${sourceDir}/jalview/schemabinding/version2">
414                                 <include name="*.java"/>
415                                 <include name="descriptors/*.java"/>
416                         </fileset>
417                 </delete>
418                 <castor-srcgen file="${schemaDir}/vamsas.xsd"
419                               todir="${sourceDir}"
420                               package="jalview.schemabinding.version2"
421                               warnings="false" 
422                                         nodesc="false"
423                                                 verbose="true"
424                                                 properties="${schemaDir}/jalview.properties"
425                 />
426                 <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd"
427                               todir="${sourceDir}"
428                               package="jalview.schemabinding.version2"
429                               warnings="false" 
430                                         nodesc="false"
431                                                 verbose="true"
432                                                 properties="${schemaDir}/jalview.properties"
433                 />
434                 <castor-srcgen file="${schemaDir}/jalview.xsd"
435                               todir="${sourceDir}"
436                               package="jalview.schemabinding.version2"
437                               warnings="false" 
438                                           nodesc="false"
439                                                 verbose="true"
440                                                 properties="${schemaDir}/jalview.properties"
441                         
442                 />
443                 <!-- 
444                 now build the jalview.binding package with the old schema set
445                 -->
446                 <delete>
447                         <fileset dir="${sourceDir}/jalview/binding/">
448                                 <include name="**"/>
449                         </fileset>
450                 </delete>
451                 <castor-srcgen file="${schemaDir}/vamsasJvV1.xsd"
452                               todir="${sourceDir}"
453                               package="jalview.binding"
454                               warnings="false" 
455                                         nodesc="true"
456                                                 verbose="true"
457                                                 properties="${schemaDir}/jalview.nodesc.properties"
458                 /> 
459                 <castor-srcgen file="${schemaDir}/JalviewUserColours.xsd"
460                               todir="${sourceDir}"
461                               package="jalview.binding"
462                               warnings="false" 
463                                         nodesc="true"
464                                                 verbose="true"
465                                                 properties="${schemaDir}/jalview.nodesc.properties"
466                 />
467                 <castor-srcgen file="${schemaDir}/jalviewJvV1.xsd"
468                               todir="${sourceDir}"
469                               package="jalview.binding"
470                               warnings="false" 
471                                           nodesc="true"
472                                                 verbose="true"
473                                                 properties="${schemaDir}/jalview.nodesc.properties"
474         />
475         </target>
476 </project>