1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 4 CDDL HEADER START 5 6 The contents of this file are subject to the terms of the 7 Common Development and Distribution License (the "License"). 8 You may not use this file except in compliance with the License. 9 10 See LICENSE.txt included in this distribution for the specific 11 language governing permissions and limitations under the License. 12 13 When distributing Covered Code, include this CDDL HEADER in each 14 file and include the License file at LICENSE.txt. 15 If applicable, add the following below this CDDL HEADER, with the 16 fields enclosed by brackets "[]" replaced with your own identifying 17 information: Portions Copyright [yyyy] [name of copyright owner] 18 19 CDDL HEADER END 20 21 Copyright 2007 Sun Microsystems, Inc. All rights reserved. 22 Use is subject to license terms. 23 24 --> 25 <project name="OpenGrok" default="jar" basedir="."> 26 <description>Builds, tests, and runs the project opengrok.</description> 27 <import file="nbproject/build-impl.xml"/> 28 29 <import file="nbproject/profiler-build-impl.xml"/> <!-- 30 31 There exist several targets which are by default empty and which can be 32 used for execution of your tasks. These targets are usually executed 33 before and after some main targets. They are: 34 35 -pre-init: called before initialization of project properties 36 -post-init: called after initialization of project properties 37 -pre-compile: called before javac compilation 38 -post-compile: called after javac compilation 39 -pre-compile-single: called before javac compilation of single file 40 -post-compile-single: called after javac compilation of single file 41 -pre-compile-test: called before javac compilation of JUnit tests 42 -post-compile-test: called after javac compilation of JUnit tests 43 -pre-compile-test-single: called before javac compilation of single JUnit test 44 -post-compile-test-single: called after javac compilation of single JUunit test 45 -pre-jar: called before JAR building 46 -post-jar: called after JAR building 47 -post-clean: called after cleaning build products 48 49 (Targets beginning with '-' are not intended to be called on their own.) 50 51 Example of inserting an obfuscator after compilation could look like this: 52 53 <target name="-post-compile"> 54 <obfuscate> 55 <fileset dir="${build.classes.dir}"/> 56 </obfuscate> 57 </target> 58 59 For list of available properties check the imported 60 nbproject/build-impl.xml file. 61 62 63 Another way to customize the build is by overriding existing main targets. 64 The targets of interest are: 65 66 -init-macrodef-javac: defines macro for javac compilation 67 -init-macrodef-junit: defines macro for junit execution 68 -init-macrodef-debug: defines macro for class debugging 69 -init-macrodef-java: defines macro for class execution 70 -do-jar-with-manifest: JAR building (if you are using a manifest) 71 -do-jar-without-manifest: JAR building (if you are not using a manifest) 72 run: execution of project 73 -javadoc-build: Javadoc generation 74 test-report: JUnit report generation 75 76 An example of overriding the target for project execution could look like this: 77 78 <target name="run" depends="opengrok-impl.jar"> 79 <exec dir="bin" executable="launcher.exe"> 80 <arg file="${dist.jar}"/> 81 </exec> 82 </target> 83 84 Notice that the overridden target depends on the jar target and not only on 85 the compile target as the regular run target does. Again, for a list of available 86 properties which you can use, check the target you are overriding in the 87 nbproject/build-impl.xml file. 88 89 --> 90 91 <property name="version" value="0.6.1"/> 92 <property name="distname" value="opengrok"/> 93 94 <taskdef classname="JFlex.anttask.JFlexTask" name="jflex" classpath="lib/JFlex.jar"/> 95 <property name="gensrcdir" value="generatedsrc"/> 96 <target name="jflex"> 97 <mkdir dir="${gensrcdir}"/> 98 <jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainXref.lex" destdir="${gensrcdir}"/> 99 <jflex file="src/org/opensolaris/opengrok/analysis/c/CSymbolTokenizer.lex" destdir="${gensrcdir}"/> 100 <jflex file="src/org/opensolaris/opengrok/analysis/c/CXref.lex" destdir="${gensrcdir}"/> 101 <jflex file="src/org/opensolaris/opengrok/analysis/java/JavaSymbolTokenizer.lex" destdir="${gensrcdir}"/> 102 <jflex file="src/org/opensolaris/opengrok/analysis/java/JavaXref.lex" destdir="${gensrcdir}"/> 103 <jflex file="src/org/opensolaris/opengrok/analysis/lisp/LispSymbolTokenizer.lex" destdir="${gensrcdir}"/> 104 <jflex file="src/org/opensolaris/opengrok/analysis/lisp/LispXref.lex" destdir="${gensrcdir}"/> 105 <jflex file="src/org/opensolaris/opengrok/analysis/tcl/TclSymbolTokenizer.lex" destdir="${gensrcdir}"/> 106 <jflex file="src/org/opensolaris/opengrok/analysis/tcl/TclXref.lex" destdir="${gensrcdir}"/> 107 <jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainFullTokenizer.lex" destdir="${gensrcdir}"/> 108 <jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainSymbolTokenizer.lex" destdir="${gensrcdir}"/> 109 <jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainXref.lex" destdir="${gensrcdir}"/> 110 <jflex file="src/org/opensolaris/opengrok/analysis/plain/XMLXref.lex" destdir="${gensrcdir}"/> 111 <jflex file="src/org/opensolaris/opengrok/analysis/sql/SQLXref.lex" destdir="${gensrcdir}"/> 112 <jflex file="src/org/opensolaris/opengrok/analysis/document/TroffXref.lex" destdir="${gensrcdir}"/> 113 <jflex file="src/org/opensolaris/opengrok/analysis/document/TroffFullTokenizer.lex" destdir="${gensrcdir}"/> 114 <jflex file="src/org/opensolaris/opengrok/analysis/sh/ShSymbolTokenizer.lex" destdir="${gensrcdir}"/> 115 <jflex file="src/org/opensolaris/opengrok/analysis/sh/ShXref.lex" destdir="${gensrcdir}"/> 116 <jflex file="src/org/opensolaris/opengrok/search/context/HistoryLineTokenizer.lex" destdir="${gensrcdir}"/> 117 <jflex file="src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex" destdir="${gensrcdir}"/> 118 </target> 119 120 <property name="hg" value="hg"/> 121 <target name="-hg-get-changeset"> 122 <exec executable="${hg}" 123 failifexecutionfails="no" 124 outputproperty="changeset"> 125 <arg value="log"/> 126 <arg value="-r"/> 127 <arg value="tip"/> 128 <redirector> 129 <outputfilterchain> 130 <filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp"> 131 <param type="regexp" value="^changeset:"/> 132 </filterreader> 133 <tokenfilter> 134 <replaceregex pattern="^changeset:[^:]*:" replace=""/> 135 </tokenfilter> 136 </outputfilterchain> 137 </redirector> 138 </exec> 139 </target> 140 141 <target name="-update-build-info" depends="-hg-get-changeset"> 142 <mkdir dir="${build.classes.dir}/org/opensolaris/opengrok"/> 143 <propertyfile 144 file="${build.classes.dir}/org/opensolaris/opengrok/info.properties"> 145 <entry key="version" value="${version}"/> 146 <entry key="changeset" value="${changeset}"/> 147 </propertyfile> 148 </target> 149 150 <property name="coverage.dir" value="${basedir}/coverage"/> 151 <target name="-pre-compile" depends="jflex"/> 152 <target name="-post-clean"> 153 <delete dir="${gensrcdir}"/> 154 <delete file="${manifest.file}"/> 155 <delete dir="${coverage.dir}"/> 156 </target> 157 158 <!-- 159 Create an empty manifest file so that nbproject/build-impl.xml 160 notices that a manifest should be added to the jar file 161 --> 162 <target name="-touch-manifest"> 163 <!-- no attributes, main-class and class-path will be added later --> 164 <manifest file="manifest.mf" mode="replace"/> 165 </target> 166 167 <target name="-pre-init" depends="-touch-manifest"/> 168 169 <!-- 170 Initialize a property holding a list of jar files on which 171 opengrok.jar depends 172 --> 173 <target name="-post-init"> 174 <pathconvert property="opengrok.lib.files" pathsep=" "> 175 <path> 176 <pathelement path="${javac.classpath}"/> 177 </path> 178 <flattenmapper/> 179 <map from="" to="lib/"/> 180 </pathconvert> 181 </target> 182 183 <!-- Update the manifest file with a classpath attribute --> 184 <target name="-update-manifest-classpath"> 185 <manifest file="${manifest.file}" mode="update"> 186 <attribute name="Class-Path" value="${opengrok.lib.files}"/> 187 </manifest> 188 </target> 189 190 <target name="-pre-jar" depends="-update-manifest-classpath,-update-build-info"/> 191 192 <!-- 193 Copy the jars from lib to dist/lib manually if we don't have 194 the copylibs task from NetBeans 195 --> 196 <target name="-copy-lib-without-netbeans" 197 unless="manifest.available+main.class+mkdist.available"> 198 <copy todir="${dist.dir}/lib"> 199 <fileset file="${file.reference.ant.jar}"/> 200 </copy> 201 <copy todir="${dist.dir}"> 202 <fileset dir="." includes="${opengrok.lib.files}"/> 203 </copy> 204 </target> 205 206 <target name="-post-jar" depends="-copy-lib-without-netbeans"> 207 <war destfile="${dist.war}" webxml="conf/web.xml"> 208 <fileset dir="web"/> 209 <fileset dir="conf" excludes="web.xml"/> 210 <lib dir="${dist.dir}" includes="opengrok.jar"/> 211 <lib dir="${dist.dir}/lib" includes="*.jar" excludes="servlet-api.jar,svn-javahl.jar"/> 212 </war> 213 <echo message="Generating man page.."/> 214 <java classname="org.opensolaris.opengrok.index.CommandLineOptions" 215 output="${dist.dir}/opengrok.1" failonerror="true" fork="true"> 216 <classpath> 217 <pathelement location="dist/opengrok.jar"/> 218 <pathelement path="${java.class.path}"/> 219 </classpath> 220 </java> 221 </target> 222 223 <target name="package" depends="jar"> 224 <exec os="SunOS" executable="/usr/bin/pkgmk"> 225 <arg line="-o -d build -r . -v ${version} -f pkgdef/prototype"/> 226 </exec> 227 <exec os="SunOS" executable="/usr/bin/pkgtrans"> 228 <arg line="-s build ../dist/OSOLopengrok-${version}.pkg OSOLopengrok"/> 229 </exec> 230 </target> 231 232 <target name="dist" depends="jar"> 233 <tar destfile="${dist.dir}/${distname}-${version}.tar.gz" 234 compression="gzip"> 235 <tarfileset dir="." prefix="${distname}-${version}"> 236 <include name="README.txt"/> 237 <include name="CHANGES.txt"/> 238 <include name="LICENSE.txt"/> 239 <include name="paths.tsv"/> 240 </tarfileset> 241 <tarfileset dir="." prefix="${distname}-${version}" mode="755"> 242 <include name="OpenGrok"/> 243 <include name="run.sh"/> 244 <include name="run-quiet.sh"/> 245 <include name="run.bat"/> 246 </tarfileset> 247 <tarfileset dir="doc" prefix="${distname}-${version}"> 248 <include name="EXAMPLE.txt"/> 249 </tarfileset> 250 <tarfileset dir="${dist.dir}" prefix="${distname}-${version}"> 251 <include name="opengrok.jar"/> 252 <include name="source.war"/> 253 <include name="lib/*"/> 254 </tarfileset> 255 </tar> 256 </target> 257 258 <target name="dist-src" depends="init"> 259 <mkdir dir="${dist.dir}"/> 260 <exec executable="hg"> 261 <arg value="archive"/> 262 <arg value="-t"/> 263 <arg value="tgz"/> 264 <arg value="${dist.dir}/${distname}-${version}-src.tar.gz"/> 265 </exec> 266 </target> 267 268 <target name="findbugs" depends="dist" description="Runs Findbugs on the OpenGrok source code"> 269 <fail message="Please install Findbugs in lib-directory to run Findbugs, see README."> 270 <condition> 271 <not> 272 <and> 273 <available file="lib/findbugs/lib/findbugs.jar"/> 274 <available file="lib/findbugs/lib/findbugs-ant.jar"/> 275 </and> 276 </not> 277 </condition> 278 </fail> 279 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="lib/findbugs/lib/findbugs-ant.jar"/> 280 <mkdir dir="findbugs"/> 281 <findbugs projectname="OpenGrok" home="lib/findbugs" output="html" excludeFilter="tools/findbugs_filter.xml" outputFile="findbugs/findbugs.html" jvmargs="-Xmx512m"> 282 <auxClasspath> 283 <fileset dir="${dist.dir}/lib/"> 284 <include name="*.jar"/> 285 </fileset> 286 </auxClasspath> 287 <sourcePath path="src" /> 288 <class location="${dist.dir}/opengrok.jar" /> 289 </findbugs> 290 </target> 291 292 <target name="emma-instrument" depends ="compile" description="Instruments the source code for Emma code coverage analysis"> 293 <fail message="Please install emma.jar and emma_ant.jar in lib-directory to run Emma, see README."> 294 <condition> 295 <not> 296 <and> 297 <available file="lib/emma.jar"/> 298 <available file="lib/emma_ant.jar"/> 299 </and> 300 </not> 301 </condition> 302 </fail> 303 <path id="emma.lib" > 304 <pathelement location="lib/emma.jar"/> 305 <pathelement location="lib/emma_ant.jar"/> 306 </path> 307 <taskdef resource="emma_ant.properties" classpathref="emma.lib"/> 308 <mkdir dir="${coverage.dir}" /> 309 <emma enabled="true"> 310 <instr instrpath="build/classes" 311 metadatafile="${coverage.dir}/coverage.em" 312 mode="overwrite" 313 filter="+org.opensolaris.*"/> 314 </emma> 315 </target> 316 317 <target name="-pre-compile-test"> 318 <property name="test-sys-prop.emma.coverage.out.file" value="${coverage.dir}/coverage.ec"/> 319 <property name="test-sys-prop.emma.coverage.out.merge" value="true"/> 320 </target> 321 322 <target name="emma-report" description="Analyze "> 323 <fail message="Please install emma.jar and emma_ant.jar in lib-directory to run Emma, see README."> 324 <condition> 325 <not> 326 <and> 327 <available file="lib/emma.jar"/> 328 <available file="lib/emma_ant.jar"/> 329 </and> 330 </not> 331 </condition> 332 </fail> 333 <taskdef resource="emma_ant.properties" classpathref="emma.lib"/> 334 <emma enabled="true" > 335 <report sourcepath="src"> 336 <!-- collect all EMMA data dumps (metadata and runtime): --> 337 <infileset dir="${coverage.dir}" includes="*.em, *.ec"/> 338 <txt outfile="${coverage.dir}/coverage.txt"/> 339 <xml outfile="${coverage.dir}/coverage.xml"/> 340 <html outfile="${coverage.dir}/index.html"/> 341 </report> 342 </emma> 343 </target> 344 345 </project> 346