blob: 657a80dae3305998b7f4766e32aee5fa96356f19 [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"/>
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}">
Pavlin Radoslavovab0b74c2013-03-14 17:18:14 -0700130 <compilerarg value="-Xlint:unchecked"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800131 </javac>
132 </target>
133
134 <target name="compile-tests" depends="compile-test"/>
135 <target name="compile-test" depends="compile">
136 <fileset dir="${resources}"/>
137 <javac includeAntRuntime="false" debug="true"
138 srcdir="${source-test}"
139 classpath="${build}"
140 classpathref="classpath-test"
141 destdir="${build-test}"/>
142 </target>
143
144 <!-- Thrift build based on http://www.flester.com/blog/2009/04/26/using-thrift-from-ant -->
145 <fileset id="thrift.files" dir="${thrift.dir}">
146 <include name="**/*.thrift"/>
147 </fileset>
148
149 <target name="gen-thrift" depends="init">
150 <pathconvert property="thrift.file.list" refid="thrift.files"
151 pathsep=" " dirsep="/">
152 </pathconvert>
153 <echo message="Running thrift generator on ${thrift.file.list}"/>
154 <exec executable="thrift" dir="${basedir}" failonerror="true">
155 <arg line="--strict -v --gen java -o ${thrift.out.dir}/.. ${thrift.file.list}"/>
156 </exec>
157 <!-- Get rid of annoying warnings in thrift java: at annotations -->
158 <echo message="Adding @SuppressWarning annotations"/>
159 <replaceregexp byline="true">
160 <regexp pattern="^public "/>
161 <substitution expression='@SuppressWarnings("all") public '/>
162 <fileset id="thrift.output.files" dir="${thrift.out.dir}/..">
163 <include name="**/*.java"/>
164 </fileset>
165 </replaceregexp>
166 </target>
167
168 <target name="clean">
169 <delete dir="${target}"/>
170 </target>
171
172 <target name="run" depends="dist">
173 <java fork="true" jar="${floodlight-jar}" classpathref="classpath">
174 <jvmarg value="-server"/>
175 <jvmarg value="-Xms1024M"/>
176 <jvmarg value="-Xmx1024M"/>
177 </java>
178 </target>
179
180 <target name="tests" depends="test"/>
181 <target name="test" depends="compile-test">
182 <junit fork="true" forkmode="once"
183 failureproperty="junit.failure"
184 printsummary="on">
185 <sysproperty key="net.sourceforge.cobertura.datafile"
186 file="${target}/cobertura.ser" />
187 <classpath>
188 <pathelement location="${build-coverage}"/>
189 <pathelement location="${build}"/>
190 <pathelement location="${build-test}"/>
191 <pathelement location="${floodlight-jar}"/>
192 <path refid="classpath-test"/>
193 </classpath>
194 <formatter type="brief" usefile="true" />
195 <batchtest todir="${test-output}">
196 <fileset dir="${source-test}">
197 <exclude name="**/storage/tests/StorageTest.java"/>
198 <include name="**/*Test*.java"/>
199 <exclude name="**/core/test/**"/>
200 <exclude name="**/core/module/**"/>
201 </fileset>
202 </batchtest>
203 </junit>
204 <fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
205 </target>
206
207 <taskdef classpathref="classpath-cobertura" resource="tasks.properties"/>
208 <target name="clean-instrument">
209 <delete file="${target}/cobertura.ser"/>
210 <delete dir="${build-coverage}"/>
211 </target>
212 <target name="instrument" depends="compile,compile-test,clean-instrument">
213 <cobertura-instrument datafile="${target}/cobertura.ser"
214 todir="${build-coverage}"
215 classpathref="classpath-cobertura">
216 <fileset dir="${build}">
217 <include name="**/*.class"/>
218 </fileset>
219 </cobertura-instrument>
220 </target>
221 <target name="coverage-report">
222 <cobertura-report format="html"
223 datafile="${target}/cobertura.ser"
224 destdir="${coverage-output}"
225 srcdir="${source}"/>
226 <cobertura-report format="xml"
227 datafile="${target}/cobertura.ser"
228 destdir="${coverage-output}"
229 srcdir="${source}"/>
230 </target>
231 <target name="coverage" depends="instrument,test,coverage-report"/>
232
Jonathan Hartef3badd2013-02-18 15:00:54 -0800233 <target name="jar" depends="compile">
234 <jar destfile="${floodlight-only-jar}">
235 <fileset dir="${build}"/>
236 <fileset dir="${resources}"/>
237 <fileset dir="${python-src}">
238 <include name="**/*.py"/>
239 </fileset>
240 </jar>
241 </target>
242
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800243 <target name="dist" depends="compile,compile-test">
244 <jar destfile="${floodlight-jar}" filesetmanifest="mergewithoutmain">
245 <manifest>
246 <attribute name="Main-Class" value="${main-class}"/>
247 <attribute name="Class-Path" value="."/>
248 </manifest>
249 <fileset dir="${build}"/>
250 <fileset dir="${resources}"/>
251 <fileset dir="${python-src}">
252 <include name="**/*.py"/>
253 </fileset>
Pankaj Berdea7d39932013-01-09 18:05:57 -0800254 <zipgroupfileset dir="${titanlib}">
255 <patternset refid="titanlib"/>
256 </zipgroupfileset>
Pankaj Berde0fc4e432013-01-12 09:47:22 -0800257 <zipgroupfileset dir="${lib}">
258 <patternset refid="lib"/>
259 </zipgroupfileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800260 </jar>
261 <jar destfile="${floodlight-test-jar}" filesetmanifest="mergewithoutmain">
262 <manifest>
263 <attribute name="Class-Path" value="."/>
264 </manifest>
265 <fileset dir="${build-test}"/>
266 <fileset dir="${resources}"/>
267 <zipgroupfileset dir="${lib}">
268 <patternset refid="lib-test"/>
269 <patternset refid="lib-cobertura"/>
270 </zipgroupfileset>
Pankaj Berdea7d39932013-01-09 18:05:57 -0800271 <zipgroupfileset dir="${titanlib}">
272 <patternset refid="titanlib"/>
273 </zipgroupfileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800274 </jar>
275 </target>
276
277 <target name="javadoc">
278 <javadoc access="protected"
279 author="true"
280 classpathref="classpath"
281 destdir="${docs}"
282 doctitle="Floodlight"
283 nodeprecated="false"
284 nodeprecatedlist="false"
285 noindex="false"
286 nonavbar="false"
287 notree="false"
288 source="1.6"
289 sourcepath="${source}"
290 splitindex="true"
291 use="true"
292 version="true"/>
293 </target>
294
295 <target name="eclipse" depends="init">
296 <pathconvert property="eclipse-lib">
297 <map from="${basedir}/" to=""/>
298 <fileset dir="${lib}">
299 <patternset refid="lib"/>
300 <patternset refid="lib-test"/>
301 </fileset>
Pankaj Berde8557a462013-01-07 08:59:31 -0800302 <fileset dir="${titanlib}">
303 <patternset refid="titanlib"/>
304 </fileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800305 </pathconvert>
306 <exec executable="${basedir}/setup-eclipse.sh">
307 <arg value="${main-class}"/>
308 <arg value="${eclipse-lib}"/>
309 </exec>
310 </target>
311
312</project>