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