Add mode comments to the classes
[proteocache.git] / build.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <project default="all" name="Build ProteoCache - Caching framework for the Dundee Resource" basedir=".">
4
5         <!-- projects details -->
6         <property name="proteocache_version" value="0.4.99"/>
7         <property name="project.url" value="http://www.compbio.dundee.ac.uk/proteocache"/>
8         <property name="product" value="ProteoCache"/>
9         <property name="author" value="Alexander Sherstnev"/>
10         <!-- Distributive file names-->
11         <property name="distdir" value="distribution"/>
12         <mkdir dir="${distdir}" />
13         <!-- products -->
14         <property name="proteocache-war" value="${distdir}/proteocache-${proteocache_version}.war"/>
15         <property name="proteocache-jar" value="${distdir}/proteocache-${proteocache_version}.jar"/>
16         <property name="proteocache-source-jar" value="${distdir}/proteocache-src-${proteocache_version}.jar"/>
17         <property name="proteocache-project" value="${distdir}/proteocache-project.zip"/>
18         <!-- java -->
19         <property name="classes" location="${basedir}/WEB-INF/classes" />
20         <property name="ext.lib.path" location="${basedir}/lib" />
21         <property name="web.lib.path" location="${basedir}/WEB-INF/lib" />
22
23         <!-- add external and internal libraries -->
24         <path id="project.classpath">
25                 <fileset dir="${web.lib.path}">
26                         <include name="*.jar" />
27                 </fileset>
28                 <fileset dir="${ext.lib.path}">
29                         <include name="*.jar" />
30                 </fileset>
31         </path>
32
33         <fileset dir="${basedir}/WEB-INF/classes/" id="allcodes">
34                 <include name="compbio/datadb/**"/>
35                 <include name="compbio/engine/**"/>
36                 <include name="compbio/server/**"/>
37         </fileset>
38
39 <!-- ###################################################################################################################################### -->
40 <!-- Main targets -->
41
42         <!-- Clean temp directories -->
43         <target name="clean">
44                 <delete dir="${classes}" />
45                 <mkdir dir="${classes}" />
46                 <copy file="${basedir}/log/log4j.properties" tofile="${classes}/log4j.properties" />
47         </target>
48
49         <!-- Clean up temporary directories and dist directory (all jar, zip, and war files deleted) -->
50         <target name="full-clean" depends="clean">
51                 <delete>
52                         <fileset dir="${distdir}">
53                                 <include name="*.jar"/>
54                                 <include name="*.zip"/>
55                                 <include name="*.war"/>
56                         </fileset>
57                 </delete>
58         </target>
59
60         <!--
61         Compile with optimisation. testsrc is not compiled
62         Packages of the lower order should not have dependencies on the packages 
63         on the next layer. So datadb (layer 3) depends on the engine classes but 
64         engine does not depend on anything in datadb
65         -->
66         <target name="compile" depends="clean" description="Multiple step compilation to ensure layered structure is preserved. Debug disabled, optimisation enabled.">
67                 <!-- copy files to class path-->
68                 <copy file="${basedir}/log/log4j.properties" tofile="${classes}/log4j.properties" />
69                 <!-- Complile engine -->
70                 <javac srcdir="${basedir}/engine" destdir="${classes}" target="1.7" source="1.7" debug="off" optimize="on" encoding="UTF-8" verbose="false" nowarn="true">
71                         <compilerarg value="-Xlint:-unchecked" />
72                         <classpath refid="project.classpath" />
73                 </javac>
74                 <!-- Complile database code -->
75                 <javac srcdir="${basedir}/datadb" destdir="${classes}" target="1.7" source="1.7" debug="off" optimize="on" encoding="UTF-8" verbose="false" nowarn="true">
76                         <compilerarg value="-Xlint:all" />
77                         <compilerarg value="-Xlint:-unchecked" />
78                         <classpath refid="project.classpath" />
79                 </javac>
80                 <!-- Complile the server -->
81                 <javac srcdir="${basedir}/server" destdir="${classes}" target="1.7" source="1.7" debug="off" optimize="on" encoding="UTF-8" verbose="false" nowarn="true">
82                         <compilerarg value="-Xlint:-unchecked" />
83                         <classpath refid="project.classpath" />
84                 </javac>
85         </target>
86
87         <target name="source-jar" description="Pack java sources">
88                 <delete file="${proteocache-source-jar}">
89                 </delete>
90                 <jar jarfile="${proteocache-source-jar}">
91                         <fileset dir="${basedir}/datadb">
92                                 <include name="**"/>
93                         </fileset>
94                         <fileset dir="${basedir}/engine">
95                                 <include name="**"/>
96                         </fileset>
97                         <fileset dir="${basedir}/server/">
98                                 <include name="**"/>
99                         </fileset>
100                         <manifest>
101                                 <attribute name="Built-By" value="${author}" />
102                                 <attribute name="Class-Path" value="." />
103                                 <attribute name="Implementation-Title" value="${product} Source Code Archive" />
104                                 <attribute name="Implementation-Vendor" value="${author}" />
105                                 <attribute name="Implementation-URL" value="${project.url}" />
106                         </manifest>
107                 </jar>
108         </target>
109
110         <target name="proteocache-jar" depends="compile" description="Pack all compiled codes, configuration, ...">
111                 <echo>Build full jar</echo>
112                 <delete file="${proteocache-jar}"></delete>
113                 <jar jarfile="${proteocache-jar}">
114 <!--                    <zipgroupfileset excludes="META-INF/*.SF" dir="${web.lib.path}" ></zipgroupfileset>-->
115                         <fileset refid="allcodes"></fileset>
116                         <fileset dir="${basedir}/WEB-INF/classes/"></fileset>
117                         <!-- Set compbio.server.MainTester as main to help user to test their deployments -->
118                         <manifest>
119                                 <attribute name="Built-By" value="${author}" />
120                                 <attribute name="Class-Path" value="." />
121                                 <attribute name="Main-Class" value="compbio.server.MainTester" />
122                                 <attribute name="Implementation-Title" value="${product}" />
123                                 <attribute name="Implementation-Vendor" value="${author}" />
124                                 <attribute name="Implementation-URL" value="${project.url}" />
125                         </manifest>
126                 </jar>
127         </target>
128
129         <target name="proteocache-server" depends="proteocache-jar" description="Prepare ProteoCache war file">
130                 <echo>Prepare ProteoCache war file</echo>
131                 <delete file="${proteocache-war}"></delete>
132                 <zip destfile="${proteocache-war}" whenempty="create">
133                         <zipfileset dir="${basedir}/WEB-INF" prefix="WEB-INF">
134                                 <exclude name="classes"/>
135                                 <include name="web.xml"/>
136                                 <include name="sun-jaxws.xml"/>
137                                 <include name="lib/*"/>
138                         </zipfileset>
139                         <zipfileset dir="." includes="${proteocache-jar}" fullpath="WEB-INF/lib/proteocache.jar"/>
140                         <zipfileset dir="${basedir}/conf" prefix="conf" />
141                         <!-- <zipfileset dir="${basedir}/META-INF" prefix="META-INF" />-->
142                         <!-- Add ProteoCache static web site pages apart from the binary archive -->
143                         <zipfileset dir="${basedir}/webapp/resources"/>
144                         <zipfileset dir="${basedir}/webapp/view" prefix="WEB-INF/view"/>
145                         <!-- Put a copy of log4j configuration file where it can be used  -->
146                         <zipfileset dir="log" includes="log4j.properties" prefix="WEB-INF/classes"/>
147                 </zip>
148         </target>
149
150         <target name="all" depends="proteocache-server, source-jar" description="Build all files"/>
151
152         <!-- This task does not really depends on compile, but it is better to make sure that the code is sound -->
153         <target name="archive" description="Pack everything in the project for those who do not have access to SVN" depends="full-clean">
154                 <delete file="${proteocache-project}">
155                 </delete>
156                 <zip destfile="${proteocache-project}" whenempty="create" >
157                         <fileset dir="." excludes="${distdir}/**, **.git, **/*.zip, **/*.war"/>
158                 </zip>
159         </target>
160
161 <!-- ###################################################################################################################################### -->
162 <!-- Test targets -->
163
164         <property name="LD_LIBRARY_PATH" value="/gridware/sge/lib/lx24-amd64"/>
165
166         <!-- add test library -->
167         <path id="test.classpath">
168                 <fileset dir="${basedir}/testsrc/lib">
169                         <include name="*.jar" />
170                 </fileset>
171                 <pathelement location="${classes}" />
172         </path>
173         <!--
174         Packages of the lower order should not have dependencies on the packages 
175         on the next layer. So datadb (layer 3) depends on the engine classes but 
176         engine does not depend on anything in datadb
177         -->
178         <target name="compile_with_debug" depends="clean" description="Perform a multiple step compilation to ensure layered structure is preserved. Debug enabled.">
179                 <!-- copy files to class path-->
180                 <copy file="${basedir}/log/log4j.properties" tofile="${classes}/log4j.properties" />
181                 <!-- Complile the engine classes -->
182                 <javac srcdir="${basedir}/engine" destdir="${classes}" target="1.7" source="1.7" debug="on" encoding="UTF-8" verbose="false" nowarn="true" >
183                         <compilerarg value="-Xlint:unchecked"/>
184                         <classpath refid="project.classpath" />
185                 </javac>
186                 <!-- Complile the database classes -->
187                 <javac srcdir="${basedir}/datadb" destdir="${classes}" target="1.7" source="1.7" debug="on" encoding="UTF-8" verbose="false" nowarn="true" >
188                         <compilerarg value="-Xlint:unchecked"/>
189                         <classpath refid="project.classpath" />
190                 </javac>
191                 <!-- Complile the server classes -->
192                 <javac srcdir="${basedir}/server" destdir="${classes}" target="1.7" source="1.7" debug="on" encoding="UTF-8" verbose="false" nowarn="true" >
193                         <compilerarg value="-Xlint:unchecked"/>
194                         <classpath refid="project.classpath" />
195                 </javac>
196                 <!-- Complile the tests -->
197                 <javac srcdir="${basedir}/testsrc" destdir="${classes}" target="1.7" source="1.7" debug="on" encoding="UTF-8" verbose="false" nowarn="true" >
198                         <compilerarg value="-Xlint:unchecked"/>
199                         <classpath refid="project.classpath" />
200                         <classpath refid="test.classpath" />
201                 </javac>
202         </target>
203
204
205         <taskdef name="testNG" classname="org.testng.TestNGAntTask">
206                 <classpath refid="test.classpath">
207                 </classpath>
208         </taskdef>
209
210         <target name="CustomTest" depends="compile_with_debug">
211                 <delete file="${activity.log}"/>
212                 <testNG haltonfailure="true" enableassert="true" >
213                         <jvmarg value="-server" />
214                         <jvmarg value="-enableassertions" />
215                         <jvmarg value="-Xms1024m" />
216                         <jvmarg value="-Xmx1024m" />
217                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
218                         <classpath refid="test.classpath" />
219                         <classpath refid="project.classpath" />
220                         <xmlfileset dir="." includes="temp-testng-customsuite.xml"/>
221                         <sysproperty key="TestingDataPath" value="${data.src}"/>
222                 </testNG>
223         </target>
224
225         <target name="Run_cluster_dependent_test" depends="compile_with_debug">
226                 <delete file="${activity.log}"/>
227                 <testNG groups="cluster" haltonfailure="true" enableassert="true" parallel="false" verbose="3">
228                         <jvmarg value="-server" />
229                         <jvmarg value="-enableassertions" />
230                         <jvmarg value="-Xms1024m" />
231                         <jvmarg value="-Xmx1024m" />
232                         <classfileset dir="${classes}" includes="**/*.class" />
233                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
234                         <classpath refid="test.classpath" />
235                         <classpath refid="project.classpath" />
236                         <sysproperty key="TestingDataPath" value="${data.src}"/>
237                 </testNG>
238         </target>
239
240         <target name="Test" depends="compile_with_debug">
241                 <delete file="${activity.log}"/>
242                 <testNG haltonfailure="true" enableassert="true" verbose="3" excludedgroups="performance, webservices" >
243                         <jvmarg value="-server" />
244                         <jvmarg value="-enableassertions" />
245                         <jvmarg value="-Xms1024m" />
246                         <jvmarg value="-Xmx1024m" />
247                         <classfileset dir="${classes}" includes="**/*.class" />
248                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
249                         <classpath refid="test.classpath" />
250                         <classpath refid="project.classpath" />
251                         <sysproperty key="TestingDataPath" value="${data.src}"/>
252                 </testNG>
253         </target>
254
255         <target name="Performance_tests" depends="compile_with_debug">
256                 <delete file="${activity.log}"/>
257                 <testNG haltonfailure="true" enableassert="true" verbose="3" groups="performance" >
258                         <jvmarg value="-server" />
259                         <jvmarg value="-enableassertions" />
260                         <jvmarg value="-Xms1024m" />
261                         <jvmarg value="-Xmx1024m" />
262                         <classfileset dir="${classes}" includes="**/*.class" />
263                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
264                         <classpath refid="test.classpath" />
265                         <classpath refid="project.classpath" />
266                         <sysproperty key="TestingDataPath" value="${data.src}"/>
267                 </testNG>
268         </target>
269
270         <target name="Test_casscode" depends="compile_with_debug">
271                 <delete file="${activity.log}"/>
272                 <testNG groups="casscode" haltonfailure="true" verbose="3" enableassert="true" >
273                         <jvmarg value="-server" />
274                         <jvmarg value="-enableassertions" />
275                         <jvmarg value="-Xms1024m" />
276                         <jvmarg value="-Xmx1024m" />
277                         <classfileset dir="${classes}" includes="**/*.class" />
278                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
279                         <classpath refid="test.classpath" />
280                         <classpath refid="project.classpath" />
281                         <sysproperty key="TestingDataPath" value="${data.src}"/>
282                 </testNG>
283         </target>
284
285         <target name="All_cluster_independent_windows_only_tests" depends="compile_with_debug">
286                 <delete file="${activity.log}" failonerror="false"/>
287                 <testNG excludedgroups="cluster, non_windows" haltonfailure="true" verbose="3" enableassert="true"  >
288                         <jvmarg value="-server" />
289                         <jvmarg value="-enableassertions" />
290                         <jvmarg value="-Xms1024m" />
291                         <jvmarg value="-Xmx1024m" />
292                         <classfileset dir="${classes}" includes="**/*.class" />
293                         <classpath refid="test.classpath" />
294                         <classpath refid="project.classpath" />
295                         <sysproperty key="TestingDataPath" value="${data.src}"/>
296                 </testNG>
297         </target>
298
299         <target name="All_cluster_independent_tests" depends="compile_with_debug">
300                 <delete file="${activity.log}" failonerror="false"/>
301                 <testNG excludedgroups="cluster, performance" haltonfailure="true" verbose="3" enableassert="true"  >
302                         <jvmarg value="-server" />
303                         <jvmarg value="-enableassertions" />
304                         <jvmarg value="-Xms1024m" />
305                         <jvmarg value="-Xmx1024m" />
306                         <classfileset dir="${classes}" includes="**/*.class" />
307                         <classpath refid="test.classpath" />
308                         <classpath refid="project.classpath" />
309                         <sysproperty key="TestingDataPath" value="${data.src}"/>
310                 </testNG>
311         </target>
312
313         <target name="Rerun_failed_tests" depends="compile_with_debug">
314                 <delete file="${activity.log}" failonerror="false"/>
315                 <testNG haltonfailure="true" enableassert="true" verbose="9" >
316                         <jvmarg value="-server" />
317                         <jvmarg value="-enableassertions" />
318                         <jvmarg value="-Xms1024m" />
319                         <jvmarg value="-Xmx1024m" />
320                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
321                         <classpath refid="test.classpath" />
322                         <classpath refid="project.classpath" />
323                         <xmlfileset dir="." includes="test-output/testng-failed.xml"/>
324                         <sysproperty key="TestingDataPath" value="${data.src}"/>
325                 </testNG>
326         </target>
327 </project>