blob: 2bd13439fbd26cebb33d2e6d1dfd1ba062e2b58f [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"/>
44 <property name="thrift.dir" value="${basedir}/src/main/thrift"/>
45 <property name="thrift.out.dir" value="lib/gen-java"/>
46 <property name="thrift.package" value="net/floodlightcontroller/packetstreamer/thrift"/>
47 <property name="ant.build.javac.source" value="1.6"/>
48 <property name="ant.build.javac.target" value="1.6"/>
49 <property name="lib" location="lib"/>
Pankaj Berde8557a462013-01-07 08:59:31 -080050 <property name="titanlib" location="lib/titan/"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080051
52 <patternset id="lib">
53 <include name="logback-classic-1.0.0.jar"/>
54 <include name="logback-core-1.0.0.jar"/>
Pankaj Berdeff421802013-01-29 20:28:52 -080055 <include name="jackson-core-asl-1.9.11.jar"/>
56 <include name="jackson-mapper-asl-1.9.11.jar"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080057 <include name="slf4j-api-1.6.4.jar"/>
58 <include name="org.restlet-2.1-RC1.jar"/>
59 <include name="org.restlet.ext.jackson-2.1-RC1.jar"/>
60 <include name="org.restlet.ext.simple-2.1-RC1.jar"/>
61 <include name="org.restlet.ext.slf4j-2.1-RC1.jar"/>
62 <include name="simple-4.1.21.jar"/>
63 <include name="netty-3.2.6.Final.jar"/>
64 <include name="args4j-2.0.16.jar"/>
Jonathan Harta47c3012013-02-01 11:28:17 -080065 <include name="concurrentlinkedhashmap-lru-1.3.jar"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080066 <include name="jython-2.5.2.jar"/>
67 <include name="libthrift-0.7.0.jar"/>
68 </patternset>
69
Pankaj Berde8557a462013-01-07 08:59:31 -080070 <patternset id="titanlib">
Pankaj Berde28cc61c2013-01-08 18:19:33 -080071 <include name="**/*.jar"/>
Pankaj Berde8557a462013-01-07 08:59:31 -080072 </patternset>
73
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080074 <path id="classpath">
75 <fileset dir="${lib}">
76 <patternset refid="lib"/>
77 </fileset>
Pankaj Berde8557a462013-01-07 08:59:31 -080078 <fileset dir="${titanlib}">
79 <patternset refid="titanlib"/>
80 </fileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080081 </path>
82
83 <patternset id="lib-cobertura">
84 <include name="cobertura-1.9.4.1.jar"/>
85 <include name="asm-3.0.jar"/>
86 <include name="asm-tree-3.0.jar"/>
87 <include name="oro/jakarta-oro-2.0.8.jar"/>
88 <include name="log4j-1.2.9.jar"/>
89 </patternset>
90 <path id="classpath-cobertura">
91 <fileset dir="${lib}">
92 <patternset refid="lib-cobertura"/>
93 </fileset>
94 </path>
95
96 <patternset id="lib-test">
97 <include name="junit-4.8.2.jar"/>
98 <include name="org.easymock-3.1.jar"/>
99 <include name="objenesis-1.2.jar"/> <!-- required by easymock to mock classes -->
100 <include name="cglib-nodep-2.2.2.jar"/> <!-- required by easymock to mock classes -->
101 </patternset>
102 <path id="classpath-test">
103 <fileset dir="${lib}">
104 <patternset refid="lib-test"/>
105 <patternset refid="lib-cobertura"/>
106 <patternset refid="lib"/>
Pankaj Berde35ad3122013-01-16 15:38:10 -0800107 <patternset refid="titanlib"/>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800108 </fileset>
109 </path>
110
111 <target name="init">
112 <mkdir dir="${build}"/>
113 <mkdir dir="${build-test}"/>
114 <mkdir dir="${target}/lib"/>
115 <mkdir dir="${thrift.out.dir}"/>
116 <mkdir dir="${test-output}"/>
117 </target>
118
119 <target name="compile" depends="init">
120 <javac includeAntRuntime="false"
121 classpathref="classpath"
122 debug="true"
123 srcdir="${source}:${thrift.out.dir}"
124 destdir="${build}">
125 </javac>
126 </target>
127
128 <target name="compile-tests" depends="compile-test"/>
129 <target name="compile-test" depends="compile">
130 <fileset dir="${resources}"/>
131 <javac includeAntRuntime="false" debug="true"
132 srcdir="${source-test}"
133 classpath="${build}"
134 classpathref="classpath-test"
135 destdir="${build-test}"/>
136 </target>
137
138 <!-- Thrift build based on http://www.flester.com/blog/2009/04/26/using-thrift-from-ant -->
139 <fileset id="thrift.files" dir="${thrift.dir}">
140 <include name="**/*.thrift"/>
141 </fileset>
142
143 <target name="gen-thrift" depends="init">
144 <pathconvert property="thrift.file.list" refid="thrift.files"
145 pathsep=" " dirsep="/">
146 </pathconvert>
147 <echo message="Running thrift generator on ${thrift.file.list}"/>
148 <exec executable="thrift" dir="${basedir}" failonerror="true">
149 <arg line="--strict -v --gen java -o ${thrift.out.dir}/.. ${thrift.file.list}"/>
150 </exec>
151 <!-- Get rid of annoying warnings in thrift java: at annotations -->
152 <echo message="Adding @SuppressWarning annotations"/>
153 <replaceregexp byline="true">
154 <regexp pattern="^public "/>
155 <substitution expression='@SuppressWarnings("all") public '/>
156 <fileset id="thrift.output.files" dir="${thrift.out.dir}/..">
157 <include name="**/*.java"/>
158 </fileset>
159 </replaceregexp>
160 </target>
161
162 <target name="clean">
163 <delete dir="${target}"/>
164 </target>
165
166 <target name="run" depends="dist">
167 <java fork="true" jar="${floodlight-jar}" classpathref="classpath">
168 <jvmarg value="-server"/>
169 <jvmarg value="-Xms1024M"/>
170 <jvmarg value="-Xmx1024M"/>
171 </java>
172 </target>
173
174 <target name="tests" depends="test"/>
175 <target name="test" depends="compile-test">
176 <junit fork="true" forkmode="once"
177 failureproperty="junit.failure"
178 printsummary="on">
179 <sysproperty key="net.sourceforge.cobertura.datafile"
180 file="${target}/cobertura.ser" />
181 <classpath>
182 <pathelement location="${build-coverage}"/>
183 <pathelement location="${build}"/>
184 <pathelement location="${build-test}"/>
185 <pathelement location="${floodlight-jar}"/>
186 <path refid="classpath-test"/>
187 </classpath>
188 <formatter type="brief" usefile="true" />
189 <batchtest todir="${test-output}">
190 <fileset dir="${source-test}">
191 <exclude name="**/storage/tests/StorageTest.java"/>
192 <include name="**/*Test*.java"/>
193 <exclude name="**/core/test/**"/>
194 <exclude name="**/core/module/**"/>
195 </fileset>
196 </batchtest>
197 </junit>
198 <fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
199 </target>
200
201 <taskdef classpathref="classpath-cobertura" resource="tasks.properties"/>
202 <target name="clean-instrument">
203 <delete file="${target}/cobertura.ser"/>
204 <delete dir="${build-coverage}"/>
205 </target>
206 <target name="instrument" depends="compile,compile-test,clean-instrument">
207 <cobertura-instrument datafile="${target}/cobertura.ser"
208 todir="${build-coverage}"
209 classpathref="classpath-cobertura">
210 <fileset dir="${build}">
211 <include name="**/*.class"/>
212 </fileset>
213 </cobertura-instrument>
214 </target>
215 <target name="coverage-report">
216 <cobertura-report format="html"
217 datafile="${target}/cobertura.ser"
218 destdir="${coverage-output}"
219 srcdir="${source}"/>
220 <cobertura-report format="xml"
221 datafile="${target}/cobertura.ser"
222 destdir="${coverage-output}"
223 srcdir="${source}"/>
224 </target>
225 <target name="coverage" depends="instrument,test,coverage-report"/>
226
227 <target name="dist" depends="compile,compile-test">
228 <jar destfile="${floodlight-jar}" filesetmanifest="mergewithoutmain">
229 <manifest>
230 <attribute name="Main-Class" value="${main-class}"/>
231 <attribute name="Class-Path" value="."/>
232 </manifest>
233 <fileset dir="${build}"/>
234 <fileset dir="${resources}"/>
235 <fileset dir="${python-src}">
236 <include name="**/*.py"/>
237 </fileset>
Pankaj Berdea7d39932013-01-09 18:05:57 -0800238 <zipgroupfileset dir="${titanlib}">
239 <patternset refid="titanlib"/>
240 </zipgroupfileset>
Pankaj Berde0fc4e432013-01-12 09:47:22 -0800241 <zipgroupfileset dir="${lib}">
242 <patternset refid="lib"/>
243 </zipgroupfileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800244 </jar>
245 <jar destfile="${floodlight-test-jar}" filesetmanifest="mergewithoutmain">
246 <manifest>
247 <attribute name="Class-Path" value="."/>
248 </manifest>
249 <fileset dir="${build-test}"/>
250 <fileset dir="${resources}"/>
251 <zipgroupfileset dir="${lib}">
252 <patternset refid="lib-test"/>
253 <patternset refid="lib-cobertura"/>
254 </zipgroupfileset>
Pankaj Berdea7d39932013-01-09 18:05:57 -0800255 <zipgroupfileset dir="${titanlib}">
256 <patternset refid="titanlib"/>
257 </zipgroupfileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800258 </jar>
259 </target>
260
261 <target name="javadoc">
262 <javadoc access="protected"
263 author="true"
264 classpathref="classpath"
265 destdir="${docs}"
266 doctitle="Floodlight"
267 nodeprecated="false"
268 nodeprecatedlist="false"
269 noindex="false"
270 nonavbar="false"
271 notree="false"
272 source="1.6"
273 sourcepath="${source}"
274 splitindex="true"
275 use="true"
276 version="true"/>
277 </target>
278
279 <target name="eclipse" depends="init">
280 <pathconvert property="eclipse-lib">
281 <map from="${basedir}/" to=""/>
282 <fileset dir="${lib}">
283 <patternset refid="lib"/>
284 <patternset refid="lib-test"/>
285 </fileset>
Pankaj Berde8557a462013-01-07 08:59:31 -0800286 <fileset dir="${titanlib}">
287 <patternset refid="titanlib"/>
288 </fileset>
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800289 </pathconvert>
290 <exec executable="${basedir}/setup-eclipse.sh">
291 <arg value="${main-class}"/>
292 <arg value="${eclipse-lib}"/>
293 </exec>
294 </target>
295
296</project>