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