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