build.xml revision fe80b749cd764b1f0f72b2f913b1fe10581911c3
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering<?xml version="1.0" encoding="UTF-8"?>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering<!--
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringCDDL HEADER START
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringThe contents of this file are subject to the terms of the
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringCommon Development and Distribution License (the "License").
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringYou may not use this file except in compliance with the License.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringSee LICENSE.txt included in this distribution for the specific
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poetteringlanguage governing permissions and limitations under the License.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringWhen distributing Covered Code, include this CDDL HEADER in each
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poetteringfile and include the License file at LICENSE.txt.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringIf applicable, add the following below this CDDL HEADER, with the
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poetteringfields enclosed by brackets "[]" replaced with your own identifying
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poetteringinformation: Portions Copyright [yyyy] [name of copyright owner]
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringCDDL HEADER END
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart PoetteringCopyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering-->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering<project name="OpenGrok" default="jar" basedir=".">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <description>Builds, tests, and runs the project opengrok.</description>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <import file="nbproject/build-impl.xml"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <import file="nbproject/profiler-build-impl.xml"/> <!--
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering There exist several targets which are by default empty and which can be
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering used for execution of your tasks. These targets are usually executed
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering before and after some main targets. They are:
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -pre-init: called before initialization of project properties
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -post-init: called after initialization of project properties
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -pre-compile: called before javac compilation
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -post-compile: called after javac compilation
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -pre-compile-single: called before javac compilation of single file
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -post-compile-single: called after javac compilation of single file
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -pre-compile-test: called before javac compilation of JUnit tests
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -post-compile-test: called after javac compilation of JUnit tests
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -pre-compile-test-single: called before javac compilation of single JUnit test
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -post-compile-test-single: called after javac compilation of single JUunit test
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -pre-jar: called before JAR building
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -post-jar: called after JAR building
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -post-clean: called after cleaning build products
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering (Targets beginning with '-' are not intended to be called on their own.)
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering Example of inserting an obfuscator after compilation could look like this:
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-post-compile">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <obfuscate>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <fileset dir="${build.classes.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </obfuscate>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering For list of available properties check the imported
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering nbproject/build-impl.xml file.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering Another way to customize the build is by overriding existing main targets.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering The targets of interest are:
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -init-macrodef-javac: defines macro for javac compilation
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -init-macrodef-junit: defines macro for junit execution
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -init-macrodef-debug: defines macro for class debugging
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -init-macrodef-java: defines macro for class execution
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -do-jar-with-manifest: JAR building (if you are using a manifest)
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -do-jar-without-manifest: JAR building (if you are not using a manifest)
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering run: execution of project
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -javadoc-build: Javadoc generation
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering test-report: JUnit report generation
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering An example of overriding the target for project execution could look like this:
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="run" depends="opengrok-impl.jar">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <exec dir="bin" executable="launcher.exe">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg file="${dist.jar}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </exec>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering Notice that the overridden target depends on the jar target and not only on
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering the compile target as the regular run target does. Again, for a list of available
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering properties which you can use, check the target you are overriding in the
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering nbproject/build-impl.xml file.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="version" value="0.10"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="distname" value="opengrok"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="findbugs.home" value="${user.home}/.ant/lib/findbugs"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="checkstyle.home" value="${user.home}/.ant/lib/checkstyle"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="pmd.home" value="${user.home}/.ant/lib/pmd"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="test.repositories" value="testdata/repositories"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="test.sources" value="testdata/sources"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="test.cvs" value="${test.repositories}/cvs"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="test.cvs.repo" value="${test.cvs}/cvsrepo"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="test.cvs.root" value="${test.cvs}/cvsroot"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="test.hg" value="${test.repositories}/mercurial"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="test.svn" value="${test.repositories}/svn"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="test.razor" value="${test.repositories}/razor"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <available property="compileSystrayClient" classname="java.awt.TrayIcon"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-exclude-client" unless="compileSystrayClient">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <echo>JDK doesn't have java.awt.TrayIcon, excluding building of systray client ... </echo>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="excludes" value="org/opensolaris/opengrok/management/client/**"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <path id="lib.search.path">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${user.home}/.ant/lib"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${java.class.path}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="lib"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="/lib"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </path>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <path id="findbugs.lib.search.path">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${findbugs.home}/lib/"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${java.class.path}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="lib/findbugs/lib/"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </path>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <path id="checkstyle.lib.search.path">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${checkstyle.home}/"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${java.class.path}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </path>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <path id="pmd.lib.search.path">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${pmd.home}/lib/"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${java.class.path}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="lib/pmd/lib/"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </path>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <available file="JFlex.jar" type="file" property="JFlex.present">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <filepath refid="lib.search.path"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </available>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <fail unless="JFlex.present" message="Please download JFlex (http://jflex.de/) and put JFlex.jar it into /lib directory (or in ant classpath)."/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <taskdef classname="JFlex.anttask.JFlexTask" name="jflex" classpathref="lib.search.path"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="jflex">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <mkdir dir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/plain/PlainXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/c/CSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/c/CXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/c/CxxSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/c/CxxXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/fortran/FortranSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/fortran/FortranXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/java/JavaSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/java/JavaXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/python/PythonSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/python/PythonXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/perl/PerlSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/perl/PerlXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/lisp/LispSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/lisp/LispXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/tcl/TclSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/tcl/TclXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/plain/PlainFullTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/plain/PlainSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/plain/PlainXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/plain/XMLXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/sql/SQLXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/document/TroffXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/document/TroffFullTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/sh/ShSymbolTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/analysis/sh/ShXref.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/search/context/HistoryLineTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <jflex file="${src.dir}/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex" destdir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="hg" value="hg"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <!-- Get the id of the changeset we're building from using a
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering Mercurial command.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-get-changeset-from-command"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering depends="-check-is-hg-repo" if="build.from.repo">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <exec executable="${hg}"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering failifexecutionfails="no"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering outputproperty="changeset">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg value="identify"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg value="--id"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </exec>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <!-- Check if we build from a checked out copy of the repository,
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering so that we have history information from Mercurial available.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-check-is-hg-repo">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <available property="build.from.repo" file=".hg" type="dir"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <!-- Get the id of the changeset we're building from by reading
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering .hg_archival.txt file created by hg archive. This will only
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering be used when we're not building from a checked out copy of
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering the repository, for example the source distribution.
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-get-changeset-from-file"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering depends="-check-is-hg-repo" unless="build.from.repo">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <tempfile property="hg.archival.temp" deleteonexit="true"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <copy file=".hg_archival.txt" tofile="${hg.archival.temp}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <replaceregexp file="${hg.archival.temp}" flags="s"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering match=".*node: ([0-9a-f]{12}).*"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering replace="\1"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <loadfile srcFile="${hg.archival.temp}" property="changeset"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-update-build-info"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering depends="-get-changeset-from-command,-get-changeset-from-file">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <mkdir dir="${build.classes.dir}/org/opensolaris/opengrok"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <propertyfile
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering file="${build.classes.dir}/org/opensolaris/opengrok/info.properties">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <entry key="version" value="${version}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <entry key="changeset" value="${changeset}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </propertyfile>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <property name="coverage.dir" value="${basedir}/coverage"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-pre-compile" depends="jrcs,jflex"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-post-clean">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <delete dir="${src.generatedsrc.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <delete file="${manifest.file}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <delete dir="${coverage.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <antcall target="-delete-generated-repository-files"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <!--
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering Create an empty manifest file so that nbproject/build-impl.xml
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering notices that a manifest should be added to the jar file
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-touch-manifest">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <!-- no attributes, main-class and class-path will be added later -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <manifest file="manifest.mf" mode="replace"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-pre-init" depends="-touch-manifest, -exclude-client"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <!--
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering Initialize a property holding a list of jar files on which
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering opengrok.jar depends
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-post-init">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathconvert property="opengrok.lib.files" pathsep=" ">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <path>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${javac.classpath}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </path>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <flattenmapper/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <map from="" to="lib/"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </pathconvert>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <!-- Update the manifest file with a classpath attribute -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-update-manifest-classpath">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <manifest file="${manifest.file}" mode="update">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <attribute name="Class-Path"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering value="${opengrok.lib.files} lib/derbyclient.jar lib/derby.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </manifest>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-pre-jar" depends="-update-manifest-classpath,-update-build-info"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <!--
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering Copy the jars from lib to dist/lib manually if we don't have
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering the copylibs task from NetBeans
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-copy-lib-without-netbeans"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering unless="manifest.available+main.class+mkdist.available">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <copy todir="${dist.dir}/lib">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <fileset file="${file.reference.ant.jar}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </copy>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <copy todir="${dist.dir}">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <fileset dir="." includes="${opengrok.lib.files}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </copy>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-post-jar" depends="-copy-lib-without-netbeans">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <war destfile="${dist.war}" webxml="web/WEB-INF/web.xml">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <fileset dir="web" excludes="META-INF/context.xml"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <lib dir="${dist.dir}" includes="opengrok.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <lib dir="${dist.dir}/lib" includes="*.jar" excludes="servlet-api.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </war>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <echo message="Generating man page.."/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <java classname="org.opensolaris.opengrok.index.CommandLineOptions"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering output="${dist.dir}/opengrok.1" failonerror="true" fork="true">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <classpath>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement location="dist/opengrok.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement path="${java.class.path}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </classpath>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </java>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="package" depends="jar">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <exec os="SunOS" executable="/usr/bin/pkgmk" failonerror="true">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg line="-o -d build -r . -v ${version} -f platform/solaris/pkgdef/prototype"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </exec>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <exec os="SunOS" executable="/usr/bin/pkgtrans" failonerror="true">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg line="-s build /dist/OSOLopengrok-${version}.pkg OSOLopengrok"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </exec>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="dist" depends="jar">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <tar destfile="${dist.dir}/${distname}-${version}.tar.gz"
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering compression="gzip">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <tarfileset dir="." prefix="${distname}-${version}/doc">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="README.txt"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="CHANGES.txt"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="LICENSE.txt"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="NOTICE.txt"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="paths.tsv"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="logging.properties"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="run.sh"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="run-quiet.sh"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="run.bat"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </tarfileset>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <tarfileset dir="." prefix="${distname}-${version}/bin" mode="755">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="OpenGrok"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </tarfileset>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <tarfileset dir="doc" prefix="${distname}-${version}/doc">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="EXAMPLE.txt"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </tarfileset>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <tarfileset dir="${dist.dir}" prefix="${distname}-${version}/lib">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="opengrok.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="source.war"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="lib/*"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <exclude name="lib/servlet-api.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </tarfileset>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <tarfileset dir="${dist.dir}" prefix="${distname}-${version}/man/man1">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="opengrok.1"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </tarfileset>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </tar>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="dist-src" depends="init">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <mkdir dir="${dist.dir}"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <exec executable="hg">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg value="archive"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg value="-t"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg value="tgz"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering<!-- <arg value="-p"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg value="${distname}-${version}-src"/> -->
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <arg value="${dist.dir}/${distname}-${version}-src.tar.gz"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </exec>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="-check_findbugs" description="Check that findbugs jar files are present">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <available file="findbugs.jar" type="file" property="findbugs.jar.present">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <filepath refid="findbugs.lib.search.path"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </available>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <fail unless="findbugs.jar.present" message="Please install Findbugs findbugs.jar in ~/.ant/lib-directory (or in ant classpath) to run Findbugs, see README"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <available file="findbugs-ant.jar" type="file" property="findbugs-ant.jar.present">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <filepath refid="findbugs.lib.search.path"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </available>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <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"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </target>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <target name="findbugs" depends="jar, -check_findbugs" description="Runs Findbugs on the OpenGrok source code and generate HTML output">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <path id="findbugs.lib" >
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <pathelement location="${findbugs.home}/lib/findbugs-ant.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </path>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs.lib"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <mkdir dir="findbugs"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <findbugs projectname="OpenGrok" home="${findbugs.home}" output="html" excludeFilter="tools/findbugs_filter.xml" outputFile="findbugs/findbugs.html" jvmargs="-Xmx512m">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <auxClasspath>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <fileset dir="${dist.dir}/lib/">
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering <include name="*.jar"/>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </fileset>
b6e676ce41508e2aeea22202fc8f234126177f52Lennart Poettering </auxClasspath>
<sourcePath path="src" />
<class location="${dist.dir}/opengrok.jar" />
</findbugs>
</target>
<target name="findbugs-xml" depends="jar, -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"/>
<fileset dir="test" 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"/>
<!-- <fileset dir="test" includes="**/*.java"/> -->
<!-- <fileset dir="web" includes="**/*.jsp"/>
<fileset dir="web" includes="**/*.jspf"/> -->
</pmd>
<echo message="PMD finished, found ${pmd.num.warnings} warnings, see pmd/pmd_report.html"/>
</target>
<target name="cpd-xml" depends="compile, -check_pmd" description="Run CPD on OpenGrok source code, print output in xml">
<path id="pmd.lib" >
<pathelement location="${pmd.home}/lib/pmd.jar"/>
<pathelement location="${pmd.home}/lib/jaxen.jar"/>
</path>
<taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="pmd.lib"/>
<cpd minimumTokenCount="100" format="xml" outputFile="pmd/cpd_report.xml">
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
<fileset dir="test">
<include name="**/*.java"/>
</fileset>
</cpd>
</target>
<target name="cpd" depends="compile, -check_pmd" description="Run CPD 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="cpd" classname="net.sourceforge.pmd.cpd.CPDTask" classpathref="pmd.lib"/>
<cpd minimumTokenCount="100" outputFile="pmd/cpd_report.txt">
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
<fileset dir="test">
<include name="**/*.java"/>
</fileset>
</cpd>
</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">${basedir}/${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="true">
<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>
<!-- Generate HTML test report -->
<target depends="init" name="test-report">
<junitreport todir="${build.test.results.dir}">
<fileset dir="${build.test.results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${build.test.results.dir}"/>
</junitreport>
</target>
<!-- Build our patched JRCS library. -->
<target name="jrcs" depends="-pre-pre-compile">
<mkdir dir="${build.dir}/jrcs"/>
<javac srcdir="jrcs/src" destdir="${build.dir}/jrcs"
nowarn="on" source="1.4"/>
<jar destfile="${file.reference.jrcs.jar}">
<fileset dir="${build.dir}/jrcs" includes="**/*.class"/>
</jar>
</target>
</project>