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