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