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