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