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