build.xml revision 781
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi<?xml version="1.0" encoding="UTF-8"?>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi<!--
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiCDDL HEADER START
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiThe contents of this file are subject to the terms of the
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiCommon Development and Distribution License (the "License").
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiYou may not use this file except in compliance with the License.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiSee LICENSE.txt included in this distribution for the specific
1d980e5489836e977ba59b419e27b0ec875c4bd3takashilanguage governing permissions and limitations under the License.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiWhen distributing Covered Code, include this CDDL HEADER in each
1d980e5489836e977ba59b419e27b0ec875c4bd3takashifile and include the License file at LICENSE.txt.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiIf applicable, add the following below this CDDL HEADER, with the
1d980e5489836e977ba59b419e27b0ec875c4bd3takashifields enclosed by brackets "[]" replaced with your own identifying
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiinformation: Portions Copyright [yyyy] [name of copyright owner]
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiCDDL HEADER END
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiCopyright 2007 Sun Microsystems, Inc. All rights reserved.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashiUse is subject to license terms.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi-->
11495c9f0bd33e51a25b4d532beadfbcf9b944a3nilgun<project name="OpenGrok" default="jar" basedir=".">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <description>Builds, tests, and runs the project opengrok.</description>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <import file="nbproject/build-impl.xml"/>
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <import file="nbproject/profiler-build-impl.xml"/> <!--
4b575a6b6704b516f22d65a3ad35696d7b9ba372rpluem
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi There exist several targets which are by default empty and which can be
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi used for execution of your tasks. These targets are usually executed
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi before and after some main targets. They are:
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -pre-init: called before initialization of project properties
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -post-init: called after initialization of project properties
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -pre-compile: called before javac compilation
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -post-compile: called after javac compilation
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -pre-compile-single: called before javac compilation of single file
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -post-compile-single: called after javac compilation of single file
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -pre-compile-test: called before javac compilation of JUnit tests
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -post-compile-test: called after javac compilation of JUnit tests
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -pre-compile-test-single: called before javac compilation of single JUnit test
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -post-compile-test-single: called after javac compilation of single JUunit test
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -pre-jar: called before JAR building
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -post-jar: called after JAR building
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -post-clean: called after cleaning build products
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi (Targets beginning with '-' are not intended to be called on their own.)
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi Example of inserting an obfuscator after compilation could look like this:
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <target name="-post-compile">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <obfuscate>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <fileset dir="${build.classes.dir}"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </obfuscate>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </target>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi For list of available properties check the imported
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi nbproject/build-impl.xml file.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi Another way to customize the build is by overriding existing main targets.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi The targets of interest are:
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -init-macrodef-javac: defines macro for javac compilation
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -init-macrodef-junit: defines macro for junit execution
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -init-macrodef-debug: defines macro for class debugging
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -init-macrodef-java: defines macro for class execution
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -do-jar-with-manifest: JAR building (if you are using a manifest)
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -do-jar-without-manifest: JAR building (if you are not using a manifest)
b9f522ae1c0ed2bf3fc4444245bf28b2e2449a65nd run: execution of project
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -javadoc-build: Javadoc generation
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi test-report: JUnit report generation
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi An example of overriding the target for project execution could look like this:
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <target name="run" depends="opengrok-impl.jar">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <exec dir="bin" executable="launcher.exe">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <arg file="${dist.jar}"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </exec>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </target>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi Notice that the overridden target depends on the jar target and not only on
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi the compile target as the regular run target does. Again, for a list of available
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi properties which you can use, check the target you are overriding in the
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi nbproject/build-impl.xml file.
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi -->
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="version" value="0.7"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="distname" value="opengrok"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="findbugs.home" value="${user.home}/.ant/lib/findbugs"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="checkstyle.home" value="${user.home}/.ant/lib/checkstyle"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="pmd.home" value="${user.home}/.ant/lib/pmd"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="test.repositories" value="testdata/repositories"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="test.sources" value="testdata/sources"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="test.cvs" value="${test.repositories}/cvs"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="test.cvs.repo" value="${test.cvs}/cvsrepo"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="test.cvs.root" value="${test.cvs}/cvsroot"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="test.hg" value="${test.repositories}/mercurial"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="test.svn" value="${test.repositories}/svn"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="test.razor" value="${test.repositories}/razor"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <available property="compileSystrayClient" classname="java.awt.TrayIcon"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <target name="-exclude-client" unless="compileSystrayClient">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <echo>JDK doesn't have java.awt.TrayIcon, excluding building of systray client ... </echo>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <property name="excludes" value="org/opensolaris/opengrok/management/client/**"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </target>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <path id="lib.search.path">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="${user.home}/.ant/lib"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="${java.class.path}"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="lib"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </path>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <path id="findbugs.lib.search.path">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="${findbugs.home}/lib/"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="${java.class.path}"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="lib/findbugs/lib/"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </path>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <path id="checkstyle.lib.search.path">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="${checkstyle.home}/"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="${java.class.path}"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="lib/checkstyle/lib/"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </path>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <path id="pmd.lib.search.path">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="${pmd.home}/lib/"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <pathelement path="${java.class.path}"/>
11495c9f0bd33e51a25b4d532beadfbcf9b944a3nilgun <pathelement path="lib/pmd/lib/"/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi </path>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung <available file="JFlex.jar" type="file" property="JFlex.present">
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <filepath refid="lib.search.path"/>
9c1260efa52c82c2a58e5b5f20cd6902563d95f5rbowen </available>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi <fail unless="JFlex.present" message="Please download JFlex (http://jflex.de/) and put JFlex.jar it into /lib directory (or in ant classpath)."/>
1d980e5489836e977ba59b419e27b0ec875c4bd3takashi
<taskdef classname="JFlex.anttask.JFlexTask" name="jflex" classpath="lib/JFlex.jar"/>
<property name="gensrcdir" value="generatedsrc"/>
<target name="jflex">
<mkdir dir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/c/CSymbolTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/c/CXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/c/CxxSymbolTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/c/CxxXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/java/JavaSymbolTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/java/JavaXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/lisp/LispSymbolTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/lisp/LispXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/tcl/TclSymbolTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/tcl/TclXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainFullTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainSymbolTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/plain/XMLXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/sql/SQLXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/document/TroffXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/document/TroffFullTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/sh/ShSymbolTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/analysis/sh/ShXref.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/search/context/HistoryLineTokenizer.lex" destdir="${gensrcdir}"/>
<jflex file="src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex" destdir="${gensrcdir}"/>
</target>
<property name="hg" value="hg"/>
<target name="-hg-get-changeset">
<exec executable="${hg}"
failifexecutionfails="no"
outputproperty="changeset">
<arg value="log"/>
<arg value="-r"/>
<arg value="tip"/>
<redirector>
<outputfilterchain>
<filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp">
<param type="regexp" value="^changeset:"/>
</filterreader>
<tokenfilter>
<replaceregex pattern="^changeset:[^:]*:" replace=""/>
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
</target>
<target name="-update-build-info" depends="-hg-get-changeset">
<mkdir dir="${build.classes.dir}/org/opensolaris/opengrok"/>
<propertyfile
file="${build.classes.dir}/org/opensolaris/opengrok/info.properties">
<entry key="version" value="${version}"/>
<entry key="changeset" value="${changeset}"/>
</propertyfile>
</target>
<property name="coverage.dir" value="${basedir}/coverage"/>
<target name="-pre-compile" depends="jflex"/>
<target name="-post-clean">
<delete dir="${gensrcdir}"/>
<delete file="${manifest.file}"/>
<delete dir="${coverage.dir}"/>
<antcall target="-delete-generated-repository-files"/>
</target>
<!--
Create an empty manifest file so that nbproject/build-impl.xml
notices that a manifest should be added to the jar file
-->
<target name="-touch-manifest">
<!-- no attributes, main-class and class-path will be added later -->
<manifest file="manifest.mf" mode="replace"/>
</target>
<target name="-pre-init" depends="-touch-manifest, -exclude-client"/>
<!--
Initialize a property holding a list of jar files on which
opengrok.jar depends
-->
<target name="-post-init">
<pathconvert property="opengrok.lib.files" pathsep=" ">
<path>
<pathelement path="${javac.classpath}"/>
</path>
<flattenmapper/>
<map from="" to="lib/"/>
</pathconvert>
</target>
<!-- Update the manifest file with a classpath attribute -->
<target name="-update-manifest-classpath">
<manifest file="${manifest.file}" mode="update">
<attribute name="Class-Path"
value="${opengrok.lib.files} lib/derby.jar"/>
</manifest>
</target>
<target name="-pre-jar" depends="-update-manifest-classpath,-update-build-info"/>
<!--
Copy the jars from lib to dist/lib manually if we don't have
the copylibs task from NetBeans
-->
<target name="-copy-lib-without-netbeans"
unless="manifest.available+main.class+mkdist.available">
<copy todir="${dist.dir}/lib">
<fileset file="${file.reference.ant.jar}"/>
</copy>
<copy todir="${dist.dir}">
<fileset dir="." includes="${opengrok.lib.files}"/>
</copy>
</target>
<target name="-post-jar" depends="-copy-lib-without-netbeans">
<war destfile="${dist.war}" webxml="conf/web.xml">
<fileset dir="web"/>
<fileset dir="conf" excludes="web.xml"/>
<lib dir="${dist.dir}" includes="opengrok.jar"/>
<lib dir="${dist.dir}/lib" includes="*.jar" excludes="servlet-api.jar"/>
</war>
<echo message="Generating man page.."/>
<java classname="org.opensolaris.opengrok.index.CommandLineOptions"
output="${dist.dir}/opengrok.1" failonerror="true" fork="true">
<classpath>
<pathelement location="dist/opengrok.jar"/>
<pathelement path="${java.class.path}"/>
</classpath>
</java>
</target>
<target name="package" depends="jar">
<exec os="SunOS" executable="/usr/bin/pkgmk">
<arg line="-o -d build -r . -v ${version} -f platform/solaris/pkgdef/prototype"/>
</exec>
<exec os="SunOS" executable="/usr/bin/pkgtrans">
<arg line="-s build /dist/OSOLopengrok-${version}.pkg OSOLopengrok"/>
</exec>
</target>
<target name="dist" depends="jar">
<tar destfile="${dist.dir}/${distname}-${version}.tar.gz"
compression="gzip">
<tarfileset dir="." prefix="${distname}-${version}">
<include name="README.txt"/>
<include name="CHANGES.txt"/>
<include name="LICENSE.txt"/>
<include name="paths.tsv"/>
</tarfileset>
<tarfileset dir="." prefix="${distname}-${version}" mode="755">
<include name="OpenGrok"/>
<include name="run.sh"/>
<include name="run-quiet.sh"/>
<include name="run.bat"/>
</tarfileset>
<tarfileset dir="doc" prefix="${distname}-${version}">
<include name="EXAMPLE.txt"/>
</tarfileset>
<tarfileset dir="${dist.dir}" prefix="${distname}-${version}">
<include name="opengrok.jar"/>
<include name="source.war"/>
<include name="lib/*"/>
<exclude name="lib/servlet-api.jar"/>
</tarfileset>
</tar>
</target>
<target name="dist-src" depends="init">
<mkdir dir="${dist.dir}"/>
<exec executable="hg">
<arg value="archive"/>
<arg value="-t"/>
<arg value="tgz"/>
<arg value="${dist.dir}/${distname}-${version}-src.tar.gz"/>
</exec>
</target>
<target name="-check_findbugs" description="Check that findbugs jar files are present">
<available file="findbugs.jar" type="file" property="findbugs.jar.present">
<filepath refid="findbugs.lib.search.path"/>
</available>
<fail unless="findbugs.jar.present" message="Please install Findbugs findbugs.jar in ~/.ant/lib-directory (or in ant classpath) to run Findbugs, see README"/>
<available file="findbugs-ant.jar" type="file" property="findbugs-ant.jar.present">
<filepath refid="findbugs.lib.search.path"/>
</available>
<fail unless="findbugs-ant.jar.present" message="Please install Findbugs findbugs-ant.jar in ~/.ant/lib-directory (or in ant classpath) to run Findbugs, see README"/>
</target>
<target name="findbugs" depends="dist, -check_findbugs" description="Runs Findbugs on the OpenGrok source code and generate HTML output">
<path id="findbugs.lib" >
<pathelement location="${findbugs.home}/lib/findbugs.jar"/>
<pathelement location="${findbugs.home}/lib/findbugs-ant.jar"/>
</path>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.lib"/>
<mkdir dir="findbugs"/>
<findbugs projectname="OpenGrok" home="${findbugs.home}" output="html" excludeFilter="tools/findbugs_filter.xml" outputFile="findbugs/findbugs.html" jvmargs="-Xmx512m">
<auxClasspath>
<fileset dir="${dist.dir}/lib/">
<include name="*.jar"/>
</fileset>
</auxClasspath>
<sourcePath path="src" />
<class location="${dist.dir}/opengrok.jar" />
</findbugs>
</target>
<target name="findbugs-xml" depends="dist, -check_findbugs" description="Runs Findbugs on the OpenGrok source code and generate XML output">
<path id="findbugs.lib" >
<pathelement location="${findbugs.home}/lib/findbugs.jar"/>
<pathelement location="${findbugs.home}/lib/findbugs-ant.jar"/>
</path>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.lib"/>
<mkdir dir="findbugs"/>
<findbugs projectname="OpenGrok" home="${findbugs.home}" output="xml" excludeFilter="tools/findbugs_filter.xml" outputFile="findbugs/findbugs.xml" jvmargs="-Xmx512m">
<auxClasspath>
<fileset dir="${dist.dir}/lib/">
<include name="*.jar"/>
</fileset>
</auxClasspath>
<sourcePath path="src" />
<class location="${dist.dir}/opengrok.jar" />
</findbugs>
</target>
<target name="-check_checkstyle" description="Check that checkstyle jar files are present">
<available file="checkstyle-all.jar" type="file" property="checkstyle.jar.present">
<filepath refid="checkstyle.lib.search.path"/>
</available>
<fail unless="checkstyle.jar.present" message="Please install checkstyle-all.jar in lib-directory (or in ant classpath) to run Checkstyle, see README."/>
</target>
<target name="checkstyle" depends="compile, -check_checkstyle" description="Run checkstyle on OpenGrok source code">
<taskdef resource="checkstyletask.properties" classpath="${checkstyle.home}/checkstyle-all.jar"/>
<checkstyle config="checkstyle/style.xml" failOnViolation="false">
<fileset dir="src" includes="**/*.java"/>
<formatter type="plain"/>
<formatter type="plain" toFile="checkstyle/checkstyle_errors.txt"/>
<formatter type="xml" toFile="checkstyle/checkstyle_errors.xml"/>
</checkstyle>
</target>
<target name="-check_pmd" description="Check that pmd jar files are present">
<available file="pmd.jar" type="file" property="pmd.jar.present">
<filepath refid="pmd.lib.search.path"/>
</available>
<fail unless="pmd.jar.present" message="Please install pmd.jar in lib-directory (or in ant classpath) to run PMD, see README."/>
</target>
<target name="pmd" depends="compile, -check_pmd" description="Run PMD on OpenGrok source code">
<path id="pmd.lib" >
<pathelement location="${pmd.home}/lib/pmd.jar"/>
<pathelement location="${pmd.home}/lib/jaxen.jar"/>
</path>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.lib"/>
<mkdir dir="pmd"/>
<pmd targetjdk="1.6" failuresPropertyName="pmd.num.warnings" rulesetfiles="tools/pmd_ruleset.xml">
<formatter type="html" toFile="pmd/pmd_report.html"/>
<formatter type="xml" toFile="pmd/pmd_report.xml"/>
<fileset dir="src" includes="**/*.java"/>
</pmd>
<echo message="PMD finished, found ${pmd.num.warnings} warnings, see pmd/pmd_report.html"/>
</target>
<target name="-check_emma" description="Check that emma jar files are present">
<available file="emma.jar" type="file" property="emma.jar.present">
<filepath refid="lib.search.path"/>
</available>
<fail unless="emma.jar.present" message="Please install emma.jar in lib-directory (or in ant classpath) to run Emma, see README."/>
<available file="emma_ant.jar" type="file" property="emma_ant.jar.present">
<filepath refid="lib.search.path"/>
</available>
<fail unless="emma_ant.jar.present" message="Please install emma_ant.jar in lib-directory (or in ant classpath) to run Emma, see README."/>
</target>
<target name="emma-instrument" depends="compile, -check_emma" description="Instruments the source code for Emma code coverage analysis">
<path id="emma.lib" >
<pathelement location="lib/emma.jar"/>
<pathelement location="lib/emma_ant.jar"/>
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib"/>
<mkdir dir="${coverage.dir}" />
<emma enabled="true">
<instr instrpath="build/classes"
metadatafile="${coverage.dir}/coverage.em"
mode="overwrite"
filter="+org.opensolaris.*,-org.opensolaris.opengrok.management.client.*"/>
</emma>
</target>
<target name="-pre-compile-test">
<property name="test-sys-prop.emma.coverage.out.file" value="${coverage.dir}/coverage.ec"/>
<property name="test-sys-prop.emma.coverage.out.merge" value="true"/>
</target>
<target name="-post-compile-test">
<antcall target="-create-svn-repository"/>
<antcall target="-create-razor-repository"/>
<!-- Change root in CVS test repository -->
<!-- Strange indentation in line two levels below to get newline correctly -->
<concat destfile="${test.cvs.repo}/CVS/Root" append="no" force="yes" eol="unix">${user.dir}/${test.cvs.root}/
</concat>
<!-- Generate ZIP files used for unit testing mercurial/.hg and mercurial/.hgignore are renamed -->
<copy todir="${test.hg}/.hg">
<fileset dir="${test.hg}/hg"/>
</copy>
<copy file="${test.hg}/hgignore" tofile="${test.hg}/.hgignore"/>
<zip destfile="${build.test.classes.dir}/org/opensolaris/opengrok/index/source.zip"
basedir="${test.sources}"
update="false"
defaultexcludes="no"/>
<zip destfile="${build.test.classes.dir}/org/opensolaris/opengrok/history/repositories.zip"
basedir="${test.repositories}"
excludes="mercurial/hg/**, mercurial/hgignore"
update="false"
defaultexcludes="no"/>
<antcall target="-delete-generated-repository-files"/>
</target>
<target name="-create-svn-repository">
<delete dir="${test.svn}"/>
<delete dir="${build.test.reposroots}/svn"/>
<mkdir dir="${build.test.reposroots}"/>
<exec executable="svnadmin" failifexecutionfails="false">
<arg value="create"/>
<arg value="${build.test.reposroots}/svn"/>
</exec>
<!-- need absolute path for svn url -->
<pathconvert property="test.svn.url">
<map from="" to="file://"/>
<path location="${build.test.reposroots}/svn"/>
</pathconvert>
<exec executable="svn" failifexecutionfails="false">
<arg value="import"/>
<arg value="${test.sources}"/>
<arg value="${test.svn.url}"/>
<arg value="-m"/>
<arg value="Initial import"/>
</exec>
<exec executable="svn" failifexecutionfails="false">
<arg value="checkout"/>
<arg value="${test.svn.url}"/>
<arg value="${test.svn}"/>
</exec>
</target>
<target name="-create-razor-repository">
<delete dir="${test.razor}"/>
<copy todir="${test.razor}/Razor-Simple">
<fileset dir="ext/SampleRazorRepository/UserSandbox"/>
</copy>
<copy todir="${test.razor}/Razor-Simple/SimpleCProgram/.razor">
<fileset dir="ext/SampleRazorRepository/Repository/OpenGrokSample/RAZOR_UNIVERSE/DOMAIN_01/Simple"/>
</copy>
<!--
The support for binaries in Razor repositories is not fully
functional, so the next copy target is commented out for now.
-->
<!--copy todir="${test.razor}/Razor-Simple/SimpleCProgram-BinaryRelease/.razor">
<fileset dir="ext/SampleRazorRepository/Repository/OpenGrokSample/RAZOR_UNIVERSE/DOMAIN_01/Simple"/>
</copy-->
</target>
<!-- clean up generated test repositories -->
<target name="-delete-generated-repository-files">
<delete dir="${test.hg}/.hg"/>
<delete file="${test.hg}/.hgignore"/>
<delete dir="${test.svn}"/>
<delete dir="${test.razor}"/>
<delete file="${test.cvs.repo}/CVS/Root"/>
</target>
<target name="emma-report" description="Analyze" depends="-check_emma">
<taskdef resource="emma_ant.properties" classpathref="emma.lib"/>
<emma enabled="true" >
<report sourcepath="${src.dir},${src.generatedsrc.dir}">
<!-- collect all EMMA data dumps (metadata and runtime): -->
<infileset dir="${coverage.dir}" includes="*.em, *.ec"/>
<txt outfile="${coverage.dir}/coverage.txt"/>
<xml outfile="${coverage.dir}/coverage.xml"/>
<html outfile="${coverage.dir}/index.html"/>
</report>
</emma>
</target>
<target name="code-coverage" depends="clean, emma-instrument, test, emma-report" description="Make test code coverage reports based on the OpenGrok unit tests"/>
<target name="jdepend" depends="compile" description="Run JDepend dependency checking">
<mkdir dir="jdepend"/>
<java classname="jdepend.xmlui.JDepend" failonerror="true" fork="true">
<arg value="-file"/>
<arg value="jdepend/report.xml"/>
<arg value="${build.classes.dir}"/>
<classpath>
<pathelement location="${user.home}/.ant/lib/jdepend/lib/jdepend.jar"/>
<pathelement path="${java.class.path}"/>
</classpath>
</java>
<java classname="jdepend.textui.JDepend" failonerror="true" fork="true">
<arg value="-file"/>
<arg value="jdepend/report.txt"/>
<arg value="${build.classes.dir}"/>
<classpath>
<pathelement location="${user.home}/.ant/lib/jdepend/lib/jdepend.jar"/>
<pathelement path="${java.class.path}"/>
</classpath>
</java>
</target>
</project>