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