Edit comments
[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="lib/*"/>
137                         </zipfileset>
138                         <zipfileset dir="." includes="${proteocache-jar}" fullpath="WEB-INF/lib/proteocache.jar"/>
139                         <zipfileset dir="${basedir}/conf" prefix="conf" />
140                         <!-- <zipfileset dir="${basedir}/META-INF" prefix="META-INF" />-->
141                         <!-- Add ProteoCache static web site pages apart from the binary archive -->
142                         <zipfileset dir="${basedir}/webapp/resources"/>
143                         <zipfileset dir="${basedir}/webapp/view" prefix="WEB-INF/view"/>
144                         <!-- Put a copy of log4j configuration file where it can be used  -->
145                         <zipfileset dir="log" includes="log4j.properties" prefix="WEB-INF/classes"/>
146                 </zip>
147         </target>
148
149         <target name="all" depends="proteocache-server, source-jar" description="Build all files"/>
150
151         <!-- This task does not really depends on compile, but it is better to make sure that the code is sound -->
152         <target name="archive" description="Pack everything in the project for those who do not have access to SVN" depends="full-clean">
153                 <delete file="${proteocache-project}">
154                 </delete>
155                 <zip destfile="${proteocache-project}" whenempty="create" >
156                         <fileset dir="." excludes="${distdir}/**, **.git, **/*.zip, **/*.war"/>
157                 </zip>
158         </target>
159
160 <!-- ###################################################################################################################################### -->
161 <!-- Test targets -->
162
163         <property name="LD_LIBRARY_PATH" value="/gridware/sge/lib/lx24-amd64"/>
164
165         <!-- add test library -->
166         <path id="test.classpath">
167                 <fileset dir="${basedir}/testsrc/lib">
168                         <include name="*.jar" />
169                 </fileset>
170                 <pathelement location="${classes}" />
171         </path>
172         <!--
173         Packages of the lower order should not have dependencies on the packages 
174         on the next layer. So datadb (layer 3) depends on the engine classes but 
175         engine does not depend on anything in datadb
176         -->
177         <target name="compile_with_debug" depends="clean" description="Perform a multiple step compilation to ensure layered structure is preserved. Debug enabled.">
178                 <!-- copy files to class path-->
179                 <copy file="${basedir}/log/log4j.properties" tofile="${classes}/log4j.properties" />
180                 <!-- Complile the engine classes -->
181                 <javac srcdir="${basedir}/engine" destdir="${classes}" target="1.7" source="1.7" debug="on" encoding="UTF-8" verbose="false" nowarn="true" >
182                         <compilerarg value="-Xlint:unchecked"/>
183                         <classpath refid="project.classpath" />
184                 </javac>
185                 <!-- Complile the database classes -->
186                 <javac srcdir="${basedir}/datadb" destdir="${classes}" target="1.7" source="1.7" debug="on" encoding="UTF-8" verbose="false" nowarn="true" >
187                         <compilerarg value="-Xlint:unchecked"/>
188                         <classpath refid="project.classpath" />
189                 </javac>
190                 <!-- Complile the server classes -->
191                 <javac srcdir="${basedir}/server" destdir="${classes}" target="1.7" source="1.7" debug="on" encoding="UTF-8" verbose="false" nowarn="true" >
192                         <compilerarg value="-Xlint:unchecked"/>
193                         <classpath refid="project.classpath" />
194                 </javac>
195                 <!-- Complile the tests -->
196                 <javac srcdir="${basedir}/testsrc" destdir="${classes}" target="1.7" source="1.7" debug="on" encoding="UTF-8" verbose="false" nowarn="true" >
197                         <compilerarg value="-Xlint:unchecked"/>
198                         <classpath refid="project.classpath" />
199                         <classpath refid="test.classpath" />
200                 </javac>
201         </target>
202
203
204         <taskdef name="testNG" classname="org.testng.TestNGAntTask">
205                 <classpath refid="test.classpath">
206                 </classpath>
207         </taskdef>
208
209         <target name="CustomTest" depends="compile_with_debug">
210                 <delete file="${activity.log}"/>
211                 <testNG haltonfailure="true" enableassert="true" >
212                         <jvmarg value="-server" />
213                         <jvmarg value="-enableassertions" />
214                         <jvmarg value="-Xms1024m" />
215                         <jvmarg value="-Xmx1024m" />
216                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
217                         <classpath refid="test.classpath" />
218                         <classpath refid="project.classpath" />
219                         <xmlfileset dir="." includes="temp-testng-customsuite.xml"/>
220                         <sysproperty key="TestingDataPath" value="${data.src}"/>
221                 </testNG>
222         </target>
223
224         <target name="Run_cluster_dependent_test" depends="compile_with_debug">
225                 <delete file="${activity.log}"/>
226                 <testNG groups="cluster" haltonfailure="true" enableassert="true" parallel="false" verbose="3">
227                         <jvmarg value="-server" />
228                         <jvmarg value="-enableassertions" />
229                         <jvmarg value="-Xms1024m" />
230                         <jvmarg value="-Xmx1024m" />
231                         <classfileset dir="${classes}" includes="**/*.class" />
232                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
233                         <classpath refid="test.classpath" />
234                         <classpath refid="project.classpath" />
235                         <sysproperty key="TestingDataPath" value="${data.src}"/>
236                 </testNG>
237         </target>
238
239         <target name="Test" depends="compile_with_debug">
240                 <delete file="${activity.log}"/>
241                 <testNG haltonfailure="true" enableassert="true" verbose="3" excludedgroups="performance, webservices" >
242                         <jvmarg value="-server" />
243                         <jvmarg value="-enableassertions" />
244                         <jvmarg value="-Xms1024m" />
245                         <jvmarg value="-Xmx1024m" />
246                         <classfileset dir="${classes}" includes="**/*.class" />
247                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
248                         <classpath refid="test.classpath" />
249                         <classpath refid="project.classpath" />
250                         <sysproperty key="TestingDataPath" value="${data.src}"/>
251                 </testNG>
252         </target>
253
254         <target name="Performance_tests" depends="compile_with_debug">
255                 <delete file="${activity.log}"/>
256                 <testNG haltonfailure="true" enableassert="true" verbose="3" groups="performance" >
257                         <jvmarg value="-server" />
258                         <jvmarg value="-enableassertions" />
259                         <jvmarg value="-Xms1024m" />
260                         <jvmarg value="-Xmx1024m" />
261                         <classfileset dir="${classes}" includes="**/*.class" />
262                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
263                         <classpath refid="test.classpath" />
264                         <classpath refid="project.classpath" />
265                         <sysproperty key="TestingDataPath" value="${data.src}"/>
266                 </testNG>
267         </target>
268
269         <target name="Test_casscode" depends="compile_with_debug">
270                 <delete file="${activity.log}"/>
271                 <testNG groups="casscode" haltonfailure="true" verbose="3" enableassert="true" >
272                         <jvmarg value="-server" />
273                         <jvmarg value="-enableassertions" />
274                         <jvmarg value="-Xms1024m" />
275                         <jvmarg value="-Xmx1024m" />
276                         <classfileset dir="${classes}" includes="**/*.class" />
277                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
278                         <classpath refid="test.classpath" />
279                         <classpath refid="project.classpath" />
280                         <sysproperty key="TestingDataPath" value="${data.src}"/>
281                 </testNG>
282         </target>
283
284         <target name="All_cluster_independent_windows_only_tests" depends="compile_with_debug">
285                 <delete file="${activity.log}" failonerror="false"/>
286                 <testNG excludedgroups="cluster, non_windows" haltonfailure="true" verbose="3" enableassert="true"  >
287                         <jvmarg value="-server" />
288                         <jvmarg value="-enableassertions" />
289                         <jvmarg value="-Xms1024m" />
290                         <jvmarg value="-Xmx1024m" />
291                         <classfileset dir="${classes}" includes="**/*.class" />
292                         <classpath refid="test.classpath" />
293                         <classpath refid="project.classpath" />
294                         <sysproperty key="TestingDataPath" value="${data.src}"/>
295                 </testNG>
296         </target>
297
298         <target name="All_cluster_independent_tests" depends="compile_with_debug">
299                 <delete file="${activity.log}" failonerror="false"/>
300                 <testNG excludedgroups="cluster, performance" haltonfailure="true" verbose="3" enableassert="true"  >
301                         <jvmarg value="-server" />
302                         <jvmarg value="-enableassertions" />
303                         <jvmarg value="-Xms1024m" />
304                         <jvmarg value="-Xmx1024m" />
305                         <classfileset dir="${classes}" includes="**/*.class" />
306                         <classpath refid="test.classpath" />
307                         <classpath refid="project.classpath" />
308                         <sysproperty key="TestingDataPath" value="${data.src}"/>
309                 </testNG>
310         </target>
311
312         <target name="Rerun_failed_tests" depends="compile_with_debug">
313                 <delete file="${activity.log}" failonerror="false"/>
314                 <testNG haltonfailure="true" enableassert="true" verbose="9" >
315                         <jvmarg value="-server" />
316                         <jvmarg value="-enableassertions" />
317                         <jvmarg value="-Xms1024m" />
318                         <jvmarg value="-Xmx1024m" />
319                         <env key="LD_LIBRARY_PATH" value="${LD_LIBRARY_PATH}"/>
320                         <classpath refid="test.classpath" />
321                         <classpath refid="project.classpath" />
322                         <xmlfileset dir="." includes="test-output/testng-failed.xml"/>
323                         <sysproperty key="TestingDataPath" value="${data.src}"/>
324                 </testNG>
325         </target>
326 </project>