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