blob: f986cea3f5a1f4da5219647d9248f54e4420e279 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
3 <!--
4 Copyright 2011, Big Switch Networks, Inc.
5
6 Licensed to the Apache Software Foundation (ASF) under one or more
7 contributor license agreements. See the NOTICE file distributed with
8 this work for additional information regarding copyright ownership.
9 The ASF licenses this file to You under the Apache License, Version 2.0
10 (the "License"); you may not use this file except in compliance with
11 the License. You may obtain a copy of the License at
12
13 http://www.apache.org/licenses/LICENSE-2.0
14
15 Unless required by applicable law or agreed to in writing, software
16 distributed under the License is distributed on an "AS IS" BASIS,
17 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 See the License for the specific language governing permissions and
19 limitations under the License.
20-->
21
22<!--
23 The build uses pregenerated Thrift code by default to reduce build
24 dependencies. To generate it locally run the gen-thrift target.
25 If you change the Thrift files be sure to also commit the updated
26 generated code.
27-->
28
Jonathan Harte4997b92013-03-22 09:57:41 -070029<project default="jar" name="Floodlight">
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080030 <property name="target" location="target"/>
31 <property name="build" location="${target}/bin"/>
32 <property name="build-test" location="${target}/bin-test"/>
33 <property name="build-coverage" location="${target}/bin-coverage"/>
34 <property name="test-output" location="${target}/test"/>
35 <property name="coverage-output" location="${target}/coverage"/>
36 <property name="source" location="src/main/java"/>
37 <property name="resources" location="src/main/resources/"/>
38 <property name="source-test" location="src/test/java"/>
39 <property name="python-src" location="src/main/python"/>
40 <property name="docs" location="${target}/docs"/>
41 <property name="main-class" value="net.floodlightcontroller.core.Main"/>
42 <property name="floodlight-jar" location="${target}/floodlight.jar"/>
43 <property name="floodlight-test-jar" location="${target}/floodlight-test.jar"/>
Jonathan Hartef3badd2013-02-18 15:00:54 -080044 <property name="floodlight-only-jar" location="${target}/floodlight-only.jar"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080045 <property name="thrift.dir" value="${basedir}/src/main/thrift"/>
46 <property name="thrift.out.dir" value="lib/gen-java"/>
47 <property name="thrift.package" value="net/floodlightcontroller/packetstreamer/thrift"/>
48 <property name="ant.build.javac.source" value="1.6"/>
49 <property name="ant.build.javac.target" value="1.6"/>
50 <property name="lib" location="lib"/>
Pankaj Berde8557a462013-01-07 08:59:31 -080051 <property name="titanlib" location="lib/titan/"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080052
53 <patternset id="lib">
54 <include name="logback-classic-1.0.0.jar"/>
55 <include name="logback-core-1.0.0.jar"/>
Pankaj Berdeff421802013-01-29 20:28:52 -080056 <include name="jackson-core-asl-1.9.11.jar"/>
57 <include name="jackson-mapper-asl-1.9.11.jar"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080058 <include name="slf4j-api-1.6.4.jar"/>
59 <include name="org.restlet-2.1-RC1.jar"/>
60 <include name="org.restlet.ext.jackson-2.1-RC1.jar"/>
61 <include name="org.restlet.ext.simple-2.1-RC1.jar"/>
62 <include name="org.restlet.ext.slf4j-2.1-RC1.jar"/>
63 <include name="simple-4.1.21.jar"/>
64 <include name="netty-3.2.6.Final.jar"/>
65 <include name="args4j-2.0.16.jar"/>
Jonathan Harta47c3012013-02-01 11:28:17 -080066 <include name="concurrentlinkedhashmap-lru-1.3.jar"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080067 <include name="jython-2.5.2.jar"/>
68 <include name="libthrift-0.7.0.jar"/>
Jonathan Hart21763562013-03-22 14:42:52 -070069 <include name="curator-client-1.3.5-SNAPSHOT.jar"/>
70 <include name="curator-framework-1.3.5-SNAPSHOT.jar"/>
71 <include name="curator-recipes-1.3.5-SNAPSHOT.jar"/>
Jonathan Hart1c451af2013-03-13 16:33:48 -070072 <include name="zookeeper-3.4.5.jar"/>
pingping-line2a09ca2013-03-23 09:33:58 +080073 <include name="ezmorph-1.0.6.jar"/>
74 <include name="json-lib-2.4-jdk15.jar"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080075 </patternset>
76
Pankaj Berde8557a462013-01-07 08:59:31 -080077 <patternset id="titanlib">
Pankaj Berde28cc61c2013-01-08 18:19:33 -080078 <include name="**/*.jar"/>
Pankaj Berde8557a462013-01-07 08:59:31 -080079 </patternset>
80
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080081 <path id="classpath">
82 <fileset dir="${lib}">
83 <patternset refid="lib"/>
84 </fileset>
Pankaj Berde8557a462013-01-07 08:59:31 -080085 <fileset dir="${titanlib}">
86 <patternset refid="titanlib"/>
87 </fileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080088 </path>
89
90 <patternset id="lib-cobertura">
91 <include name="cobertura-1.9.4.1.jar"/>
92 <include name="asm-3.0.jar"/>
93 <include name="asm-tree-3.0.jar"/>
94 <include name="oro/jakarta-oro-2.0.8.jar"/>
95 <include name="log4j-1.2.9.jar"/>
96 </patternset>
97 <path id="classpath-cobertura">
98 <fileset dir="${lib}">
99 <patternset refid="lib-cobertura"/>
100 </fileset>
101 </path>
102
103 <patternset id="lib-test">
104 <include name="junit-4.8.2.jar"/>
105 <include name="org.easymock-3.1.jar"/>
106 <include name="objenesis-1.2.jar"/> <!-- required by easymock to mock classes -->
107 <include name="cglib-nodep-2.2.2.jar"/> <!-- required by easymock to mock classes -->
108 </patternset>
109 <path id="classpath-test">
110 <fileset dir="${lib}">
111 <patternset refid="lib-test"/>
112 <patternset refid="lib-cobertura"/>
113 <patternset refid="lib"/>
Pankaj Berde35ad3122013-01-16 15:38:10 -0800114 <patternset refid="titanlib"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800115 </fileset>
116 </path>
117
118 <target name="init">
119 <mkdir dir="${build}"/>
120 <mkdir dir="${build-test}"/>
121 <mkdir dir="${target}/lib"/>
122 <mkdir dir="${thrift.out.dir}"/>
123 <mkdir dir="${test-output}"/>
124 </target>
125
126 <target name="compile" depends="init">
127 <javac includeAntRuntime="false"
128 classpathref="classpath"
129 debug="true"
130 srcdir="${source}:${thrift.out.dir}"
131 destdir="${build}">
Pavlin Radoslavovab0b74c2013-03-14 17:18:14 -0700132 <compilerarg value="-Xlint:unchecked"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800133 </javac>
134 </target>
135
136 <target name="compile-tests" depends="compile-test"/>
137 <target name="compile-test" depends="compile">
138 <fileset dir="${resources}"/>
139 <javac includeAntRuntime="false" debug="true"
140 srcdir="${source-test}"
141 classpath="${build}"
142 classpathref="classpath-test"
143 destdir="${build-test}"/>
144 </target>
145
146 <!-- Thrift build based on http://www.flester.com/blog/2009/04/26/using-thrift-from-ant -->
147 <fileset id="thrift.files" dir="${thrift.dir}">
148 <include name="**/*.thrift"/>
149 </fileset>
150
151 <target name="gen-thrift" depends="init">
152 <pathconvert property="thrift.file.list" refid="thrift.files"
153 pathsep=" " dirsep="/">
154 </pathconvert>
155 <echo message="Running thrift generator on ${thrift.file.list}"/>
156 <exec executable="thrift" dir="${basedir}" failonerror="true">
157 <arg line="--strict -v --gen java -o ${thrift.out.dir}/.. ${thrift.file.list}"/>
158 </exec>
159 <!-- Get rid of annoying warnings in thrift java: at annotations -->
160 <echo message="Adding @SuppressWarning annotations"/>
161 <replaceregexp byline="true">
162 <regexp pattern="^public "/>
163 <substitution expression='@SuppressWarnings("all") public '/>
164 <fileset id="thrift.output.files" dir="${thrift.out.dir}/..">
165 <include name="**/*.java"/>
166 </fileset>
167 </replaceregexp>
168 </target>
169
170 <target name="clean">
171 <delete dir="${target}"/>
172 </target>
173
174 <target name="run" depends="dist">
175 <java fork="true" jar="${floodlight-jar}" classpathref="classpath">
176 <jvmarg value="-server"/>
177 <jvmarg value="-Xms1024M"/>
178 <jvmarg value="-Xmx1024M"/>
179 </java>
180 </target>
181
182 <target name="tests" depends="test"/>
183 <target name="test" depends="compile-test">
184 <junit fork="true" forkmode="once"
185 failureproperty="junit.failure"
186 printsummary="on">
187 <sysproperty key="net.sourceforge.cobertura.datafile"
188 file="${target}/cobertura.ser" />
189 <classpath>
190 <pathelement location="${build-coverage}"/>
191 <pathelement location="${build}"/>
192 <pathelement location="${build-test}"/>
193 <pathelement location="${floodlight-jar}"/>
194 <path refid="classpath-test"/>
195 </classpath>
196 <formatter type="brief" usefile="true" />
197 <batchtest todir="${test-output}">
198 <fileset dir="${source-test}">
199 <exclude name="**/storage/tests/StorageTest.java"/>
200 <include name="**/*Test*.java"/>
201 <exclude name="**/core/test/**"/>
202 <exclude name="**/core/module/**"/>
203 </fileset>
204 </batchtest>
205 </junit>
206 <fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
207 </target>
208
209 <taskdef classpathref="classpath-cobertura" resource="tasks.properties"/>
210 <target name="clean-instrument">
211 <delete file="${target}/cobertura.ser"/>
212 <delete dir="${build-coverage}"/>
213 </target>
214 <target name="instrument" depends="compile,compile-test,clean-instrument">
215 <cobertura-instrument datafile="${target}/cobertura.ser"
216 todir="${build-coverage}"
217 classpathref="classpath-cobertura">
218 <fileset dir="${build}">
219 <include name="**/*.class"/>
220 </fileset>
221 </cobertura-instrument>
222 </target>
223 <target name="coverage-report">
224 <cobertura-report format="html"
225 datafile="${target}/cobertura.ser"
226 destdir="${coverage-output}"
227 srcdir="${source}"/>
228 <cobertura-report format="xml"
229 datafile="${target}/cobertura.ser"
230 destdir="${coverage-output}"
231 srcdir="${source}"/>
232 </target>
233 <target name="coverage" depends="instrument,test,coverage-report"/>
234
Jonathan Hartef3badd2013-02-18 15:00:54 -0800235 <target name="jar" depends="compile">
236 <jar destfile="${floodlight-only-jar}">
237 <fileset dir="${build}"/>
238 <fileset dir="${resources}"/>
239 <fileset dir="${python-src}">
240 <include name="**/*.py"/>
241 </fileset>
242 </jar>
243 </target>
244
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800245 <target name="dist" depends="compile,compile-test">
246 <jar destfile="${floodlight-jar}" filesetmanifest="mergewithoutmain">
247 <manifest>
248 <attribute name="Main-Class" value="${main-class}"/>
249 <attribute name="Class-Path" value="."/>
250 </manifest>
251 <fileset dir="${build}"/>
252 <fileset dir="${resources}"/>
253 <fileset dir="${python-src}">
254 <include name="**/*.py"/>
255 </fileset>
Pankaj Berdea7d39932013-01-09 18:05:57 -0800256 <zipgroupfileset dir="${titanlib}">
257 <patternset refid="titanlib"/>
258 </zipgroupfileset>
Pankaj Berde0fc4e432013-01-12 09:47:22 -0800259 <zipgroupfileset dir="${lib}">
260 <patternset refid="lib"/>
261 </zipgroupfileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800262 </jar>
263 <jar destfile="${floodlight-test-jar}" filesetmanifest="mergewithoutmain">
264 <manifest>
265 <attribute name="Class-Path" value="."/>
266 </manifest>
267 <fileset dir="${build-test}"/>
268 <fileset dir="${resources}"/>
269 <zipgroupfileset dir="${lib}">
270 <patternset refid="lib-test"/>
271 <patternset refid="lib-cobertura"/>
272 </zipgroupfileset>
Pankaj Berdea7d39932013-01-09 18:05:57 -0800273 <zipgroupfileset dir="${titanlib}">
274 <patternset refid="titanlib"/>
275 </zipgroupfileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800276 </jar>
277 </target>
278
279 <target name="javadoc">
280 <javadoc access="protected"
281 author="true"
282 classpathref="classpath"
283 destdir="${docs}"
284 doctitle="Floodlight"
285 nodeprecated="false"
286 nodeprecatedlist="false"
287 noindex="false"
288 nonavbar="false"
289 notree="false"
290 source="1.6"
291 sourcepath="${source}"
292 splitindex="true"
293 use="true"
294 version="true"/>
295 </target>
296
297 <target name="eclipse" depends="init">
298 <pathconvert property="eclipse-lib">
299 <map from="${basedir}/" to=""/>
300 <fileset dir="${lib}">
301 <patternset refid="lib"/>
302 <patternset refid="lib-test"/>
303 </fileset>
Pankaj Berde8557a462013-01-07 08:59:31 -0800304 <fileset dir="${titanlib}">
305 <patternset refid="titanlib"/>
306 </fileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800307 </pathconvert>
308 <exec executable="${basedir}/setup-eclipse.sh">
309 <arg value="${main-class}"/>
310 <arg value="${eclipse-lib}"/>
311 </exec>
312 </target>
313
314</project>