blob: e8055e7e1487484bd4df768e1d62ab8375303e33 [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
29<project default="dist" name="Floodlight">
30 <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 Hart1c451af2013-03-13 16:33:48 -070069 <include name="curator-client-1.3.3.jar"/>
70 <include name="curator-framework-1.3.3.jar"/>
71 <include name="curator-recipes-1.3.3.jar"/>
72 <include name="zookeeper-3.4.5.jar"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080073 </patternset>
74
Pankaj Berde8557a462013-01-07 08:59:31 -080075 <patternset id="titanlib">
Pankaj Berde28cc61c2013-01-08 18:19:33 -080076 <include name="**/*.jar"/>
Pankaj Berde8557a462013-01-07 08:59:31 -080077 </patternset>
78
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080079 <path id="classpath">
80 <fileset dir="${lib}">
81 <patternset refid="lib"/>
82 </fileset>
Pankaj Berde8557a462013-01-07 08:59:31 -080083 <fileset dir="${titanlib}">
84 <patternset refid="titanlib"/>
85 </fileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080086 </path>
87
88 <patternset id="lib-cobertura">
89 <include name="cobertura-1.9.4.1.jar"/>
90 <include name="asm-3.0.jar"/>
91 <include name="asm-tree-3.0.jar"/>
92 <include name="oro/jakarta-oro-2.0.8.jar"/>
93 <include name="log4j-1.2.9.jar"/>
94 </patternset>
95 <path id="classpath-cobertura">
96 <fileset dir="${lib}">
97 <patternset refid="lib-cobertura"/>
98 </fileset>
99 </path>
100
101 <patternset id="lib-test">
102 <include name="junit-4.8.2.jar"/>
103 <include name="org.easymock-3.1.jar"/>
104 <include name="objenesis-1.2.jar"/> <!-- required by easymock to mock classes -->
105 <include name="cglib-nodep-2.2.2.jar"/> <!-- required by easymock to mock classes -->
106 </patternset>
107 <path id="classpath-test">
108 <fileset dir="${lib}">
109 <patternset refid="lib-test"/>
110 <patternset refid="lib-cobertura"/>
111 <patternset refid="lib"/>
Pankaj Berde35ad3122013-01-16 15:38:10 -0800112 <patternset refid="titanlib"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800113 </fileset>
114 </path>
115
116 <target name="init">
117 <mkdir dir="${build}"/>
118 <mkdir dir="${build-test}"/>
119 <mkdir dir="${target}/lib"/>
120 <mkdir dir="${thrift.out.dir}"/>
121 <mkdir dir="${test-output}"/>
122 </target>
123
124 <target name="compile" depends="init">
125 <javac includeAntRuntime="false"
126 classpathref="classpath"
127 debug="true"
128 srcdir="${source}:${thrift.out.dir}"
129 destdir="${build}">
130 </javac>
131 </target>
132
133 <target name="compile-tests" depends="compile-test"/>
134 <target name="compile-test" depends="compile">
135 <fileset dir="${resources}"/>
136 <javac includeAntRuntime="false" debug="true"
137 srcdir="${source-test}"
138 classpath="${build}"
139 classpathref="classpath-test"
140 destdir="${build-test}"/>
141 </target>
142
143 <!-- Thrift build based on http://www.flester.com/blog/2009/04/26/using-thrift-from-ant -->
144 <fileset id="thrift.files" dir="${thrift.dir}">
145 <include name="**/*.thrift"/>
146 </fileset>
147
148 <target name="gen-thrift" depends="init">
149 <pathconvert property="thrift.file.list" refid="thrift.files"
150 pathsep=" " dirsep="/">
151 </pathconvert>
152 <echo message="Running thrift generator on ${thrift.file.list}"/>
153 <exec executable="thrift" dir="${basedir}" failonerror="true">
154 <arg line="--strict -v --gen java -o ${thrift.out.dir}/.. ${thrift.file.list}"/>
155 </exec>
156 <!-- Get rid of annoying warnings in thrift java: at annotations -->
157 <echo message="Adding @SuppressWarning annotations"/>
158 <replaceregexp byline="true">
159 <regexp pattern="^public "/>
160 <substitution expression='@SuppressWarnings("all") public '/>
161 <fileset id="thrift.output.files" dir="${thrift.out.dir}/..">
162 <include name="**/*.java"/>
163 </fileset>
164 </replaceregexp>
165 </target>
166
167 <target name="clean">
168 <delete dir="${target}"/>
169 </target>
170
171 <target name="run" depends="dist">
172 <java fork="true" jar="${floodlight-jar}" classpathref="classpath">
173 <jvmarg value="-server"/>
174 <jvmarg value="-Xms1024M"/>
175 <jvmarg value="-Xmx1024M"/>
176 </java>
177 </target>
178
179 <target name="tests" depends="test"/>
180 <target name="test" depends="compile-test">
181 <junit fork="true" forkmode="once"
182 failureproperty="junit.failure"
183 printsummary="on">
184 <sysproperty key="net.sourceforge.cobertura.datafile"
185 file="${target}/cobertura.ser" />
186 <classpath>
187 <pathelement location="${build-coverage}"/>
188 <pathelement location="${build}"/>
189 <pathelement location="${build-test}"/>
190 <pathelement location="${floodlight-jar}"/>
191 <path refid="classpath-test"/>
192 </classpath>
193 <formatter type="brief" usefile="true" />
194 <batchtest todir="${test-output}">
195 <fileset dir="${source-test}">
196 <exclude name="**/storage/tests/StorageTest.java"/>
197 <include name="**/*Test*.java"/>
198 <exclude name="**/core/test/**"/>
199 <exclude name="**/core/module/**"/>
200 </fileset>
201 </batchtest>
202 </junit>
203 <fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
204 </target>
205
206 <taskdef classpathref="classpath-cobertura" resource="tasks.properties"/>
207 <target name="clean-instrument">
208 <delete file="${target}/cobertura.ser"/>
209 <delete dir="${build-coverage}"/>
210 </target>
211 <target name="instrument" depends="compile,compile-test,clean-instrument">
212 <cobertura-instrument datafile="${target}/cobertura.ser"
213 todir="${build-coverage}"
214 classpathref="classpath-cobertura">
215 <fileset dir="${build}">
216 <include name="**/*.class"/>
217 </fileset>
218 </cobertura-instrument>
219 </target>
220 <target name="coverage-report">
221 <cobertura-report format="html"
222 datafile="${target}/cobertura.ser"
223 destdir="${coverage-output}"
224 srcdir="${source}"/>
225 <cobertura-report format="xml"
226 datafile="${target}/cobertura.ser"
227 destdir="${coverage-output}"
228 srcdir="${source}"/>
229 </target>
230 <target name="coverage" depends="instrument,test,coverage-report"/>
231
Jonathan Hartef3badd2013-02-18 15:00:54 -0800232 <target name="jar" depends="compile">
233 <jar destfile="${floodlight-only-jar}">
234 <fileset dir="${build}"/>
235 <fileset dir="${resources}"/>
236 <fileset dir="${python-src}">
237 <include name="**/*.py"/>
238 </fileset>
239 </jar>
240 </target>
241
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800242 <target name="dist" depends="compile,compile-test">
243 <jar destfile="${floodlight-jar}" filesetmanifest="mergewithoutmain">
244 <manifest>
245 <attribute name="Main-Class" value="${main-class}"/>
246 <attribute name="Class-Path" value="."/>
247 </manifest>
248 <fileset dir="${build}"/>
249 <fileset dir="${resources}"/>
250 <fileset dir="${python-src}">
251 <include name="**/*.py"/>
252 </fileset>
Pankaj Berdea7d39932013-01-09 18:05:57 -0800253 <zipgroupfileset dir="${titanlib}">
254 <patternset refid="titanlib"/>
255 </zipgroupfileset>
Pankaj Berde0fc4e432013-01-12 09:47:22 -0800256 <zipgroupfileset dir="${lib}">
257 <patternset refid="lib"/>
258 </zipgroupfileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800259 </jar>
260 <jar destfile="${floodlight-test-jar}" filesetmanifest="mergewithoutmain">
261 <manifest>
262 <attribute name="Class-Path" value="."/>
263 </manifest>
264 <fileset dir="${build-test}"/>
265 <fileset dir="${resources}"/>
266 <zipgroupfileset dir="${lib}">
267 <patternset refid="lib-test"/>
268 <patternset refid="lib-cobertura"/>
269 </zipgroupfileset>
Pankaj Berdea7d39932013-01-09 18:05:57 -0800270 <zipgroupfileset dir="${titanlib}">
271 <patternset refid="titanlib"/>
272 </zipgroupfileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800273 </jar>
274 </target>
275
276 <target name="javadoc">
277 <javadoc access="protected"
278 author="true"
279 classpathref="classpath"
280 destdir="${docs}"
281 doctitle="Floodlight"
282 nodeprecated="false"
283 nodeprecatedlist="false"
284 noindex="false"
285 nonavbar="false"
286 notree="false"
287 source="1.6"
288 sourcepath="${source}"
289 splitindex="true"
290 use="true"
291 version="true"/>
292 </target>
293
294 <target name="eclipse" depends="init">
295 <pathconvert property="eclipse-lib">
296 <map from="${basedir}/" to=""/>
297 <fileset dir="${lib}">
298 <patternset refid="lib"/>
299 <patternset refid="lib-test"/>
300 </fileset>
Pankaj Berde8557a462013-01-07 08:59:31 -0800301 <fileset dir="${titanlib}">
302 <patternset refid="titanlib"/>
303 </fileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800304 </pathconvert>
305 <exec executable="${basedir}/setup-eclipse.sh">
306 <arg value="${main-class}"/>
307 <arg value="${eclipse-lib}"/>
308 </exec>
309 </target>
310
311</project>