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