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