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