build.xml revision 446
1281N/A<?xml version="1.0" encoding="UTF-8"?>
1186N/A<!--
1186N/A
0N/ACDDL HEADER START
0N/A
0N/AThe contents of this file are subject to the terms of the
1281N/ACommon Development and Distribution License (the "License").
0N/AYou may not use this file except in compliance with the License.
0N/A
0N/ASee LICENSE.txt included in this distribution for the specific
0N/Alanguage governing permissions and limitations under the License.
0N/A
0N/AWhen distributing Covered Code, include this CDDL HEADER in each
0N/Afile and include the License file at LICENSE.txt.
0N/AIf applicable, add the following below this CDDL HEADER, with the
0N/Afields enclosed by brackets "[]" replaced with your own identifying
0N/Ainformation: Portions Copyright [yyyy] [name of copyright owner]
0N/A
0N/ACDDL HEADER END
0N/A
1297N/ACopyright 2007 Sun Microsystems, Inc. All rights reserved.
0N/AUse is subject to license terms.
1356N/A
1186N/A-->
1186N/A<project name="OpenGrok" default="jar" basedir=".">
1466N/A <description>Builds, tests, and runs the project opengrok.</description>
1186N/A <import file="nbproject/build-impl.xml"/>
1186N/A
1186N/A <import file="nbproject/profiler-build-impl.xml"/> <!--
1478N/A
1186N/A There exist several targets which are by default empty and which can be
1186N/A used for execution of your tasks. These targets are usually executed
0N/A before and after some main targets. They are:
1478N/A
1478N/A -pre-init: called before initialization of project properties
1478N/A -post-init: called after initialization of project properties
1186N/A -pre-compile: called before javac compilation
1186N/A -post-compile: called after javac compilation
1355N/A -pre-compile-single: called before javac compilation of single file
1478N/A -post-compile-single: called after javac compilation of single file
1478N/A -pre-compile-test: called before javac compilation of JUnit tests
1478N/A -post-compile-test: called after javac compilation of JUnit tests
1478N/A -pre-compile-test-single: called before javac compilation of single JUnit test
1186N/A -post-compile-test-single: called after javac compilation of single JUunit test
1186N/A -pre-jar: called before JAR building
1478N/A -post-jar: called after JAR building
962N/A -post-clean: called after cleaning build products
1186N/A
1186N/A (Targets beginning with '-' are not intended to be called on their own.)
1281N/A
1281N/A Example of inserting an obfuscator after compilation could look like this:
1281N/A
1281N/A <target name="-post-compile">
1281N/A <obfuscate>
1470N/A <fileset dir="${build.classes.dir}"/>
1281N/A </obfuscate>
962N/A </target>
1281N/A
1470N/A For list of available properties check the imported
1470N/A nbproject/build-impl.xml file.
1281N/A
1281N/A
1281N/A Another way to customize the build is by overriding existing main targets.
1281N/A The targets of interest are:
1281N/A
1470N/A -init-macrodef-javac: defines macro for javac compilation
1470N/A -init-macrodef-junit: defines macro for junit execution
1281N/A -init-macrodef-debug: defines macro for class debugging
1281N/A -init-macrodef-java: defines macro for class execution
1281N/A -do-jar-with-manifest: JAR building (if you are using a manifest)
1281N/A -do-jar-without-manifest: JAR building (if you are not using a manifest)
1470N/A run: execution of project
1470N/A -javadoc-build: Javadoc generation
1281N/A test-report: JUnit report generation
1281N/A
1281N/A An example of overriding the target for project execution could look like this:
1281N/A
1281N/A <target name="run" depends="opengrok-impl.jar">
1466N/A <exec dir="bin" executable="launcher.exe">
1281N/A <arg file="${dist.jar}"/>
1466N/A </exec>
1466N/A </target>
1466N/A
1281N/A Notice that the overridden target depends on the jar target and not only on
1281N/A the compile target as the regular run target does. Again, for a list of available
1281N/A properties which you can use, check the target you are overriding in the
1281N/A nbproject/build-impl.xml file.
1281N/A
1186N/A -->
1355N/A
1354N/A <property name="version" value="0.6.1"/>
1186N/A <property name="distname" value="opengrok"/>
1186N/A
1186N/A <property name="findbugs.home" value="${user.home}/.ant/lib/findbugs"/>
1281N/A <property name="checkstyle.home" value="${user.home}/.ant/lib/checkstyle"/>
1466N/A <property name="pmd.home" value="${user.home}/.ant/lib/pmd"/>
1281N/A
1281N/A <path id="lib.search.path">
1281N/A <pathelement path="${user.home}/.ant/lib"/>
1281N/A <pathelement path="${java.class.path}"/>
1281N/A <pathelement path="lib"/>
1390N/A </path>
1281N/A
1281N/A <path id="findbugs.lib.search.path">
1281N/A <pathelement path="${findbugs.home}/lib/"/>
1281N/A <pathelement path="${java.class.path}/findbugs/lib/"/>
1469N/A <pathelement path="lib/findbugs/lib/"/>
1281N/A </path>
1281N/A
1281N/A <path id="checkstyle.lib.search.path">
1281N/A <pathelement path="${checkstyle.home}/"/>
1481N/A <pathelement path="${java.class.path}/checkstyle/"/>
1481N/A <pathelement path="lib/checkstyle/lib/"/>
1481N/A </path>
1481N/A
1481N/A <path id="pmd.lib.search.path">
1481N/A <pathelement path="${pmd.home}/lib/"/>
1481N/A <pathelement path="${java.class.path}/pmd/lib/"/>
1481N/A <pathelement path="lib/pmd/lib/"/>
1481N/A </path>
1481N/A
1481N/A <available file="JFlex.jar" type="file" property="JFlex.present">
1481N/A <filepath refid="lib.search.path"/>
1481N/A </available>
1481N/A <fail unless="JFlex.present" message="Please download JFlex (http://jflex.de/) and put JFlex.jar it into /lib directory (or in ant classpath)."/>
1481N/A
1481N/A <taskdef classname="JFlex.anttask.JFlexTask" name="jflex" classpath="lib/JFlex.jar"/>
1481N/A <property name="gensrcdir" value="generatedsrc"/>
1481N/A <target name="jflex">
1481N/A <mkdir dir="${gensrcdir}"/>
1481N/A <jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainXref.lex" destdir="${gensrcdir}"/>
1481N/A <jflex file="src/org/opensolaris/opengrok/analysis/c/CSymbolTokenizer.lex" destdir="${gensrcdir}"/>
1481N/A <jflex file="src/org/opensolaris/opengrok/analysis/c/CXref.lex" destdir="${gensrcdir}"/>
1481N/A <jflex file="src/org/opensolaris/opengrok/analysis/java/JavaSymbolTokenizer.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/java/JavaXref.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/lisp/LispSymbolTokenizer.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/lisp/LispXref.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/tcl/TclSymbolTokenizer.lex" destdir="${gensrcdir}"/>
1481N/A <jflex file="src/org/opensolaris/opengrok/analysis/tcl/TclXref.lex" destdir="${gensrcdir}"/>
1355N/A <jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainFullTokenizer.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainSymbolTokenizer.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/plain/PlainXref.lex" destdir="${gensrcdir}"/>
1481N/A <jflex file="src/org/opensolaris/opengrok/analysis/plain/XMLXref.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/sql/SQLXref.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/document/TroffXref.lex" destdir="${gensrcdir}"/>
1355N/A <jflex file="src/org/opensolaris/opengrok/analysis/document/TroffFullTokenizer.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/analysis/sh/ShSymbolTokenizer.lex" destdir="${gensrcdir}"/>
1355N/A <jflex file="src/org/opensolaris/opengrok/analysis/sh/ShXref.lex" destdir="${gensrcdir}"/>
1281N/A <jflex file="src/org/opensolaris/opengrok/search/context/HistoryLineTokenizer.lex" destdir="${gensrcdir}"/>
1355N/A <jflex file="src/org/opensolaris/opengrok/search/context/PlainLineTokenizer.lex" destdir="${gensrcdir}"/>
1466N/A </target>
1281N/A
1281N/A <property name="hg" value="hg"/>
1355N/A <target name="-hg-get-changeset">
1281N/A <exec executable="${hg}"
1355N/A failifexecutionfails="no"
1466N/A outputproperty="changeset">
1355N/A <arg value="log"/>
1355N/A <arg value="-r"/>
1281N/A <arg value="tip"/>
1281N/A <redirector>
1281N/A <outputfilterchain>
1281N/A <filterreader classname="org.apache.tools.ant.filters.LineContainsRegExp">
1281N/A <param type="regexp" value="^changeset:"/>
1281N/A </filterreader>
1281N/A <tokenfilter>
1281N/A <replaceregex pattern="^changeset:[^:]*:" replace=""/>
1281N/A </tokenfilter>
1281N/A </outputfilterchain>
1281N/A </redirector>
1281N/A </exec>
1281N/A </target>
1281N/A
1281N/A <target name="-update-build-info" depends="-hg-get-changeset">
1281N/A <mkdir dir="${build.classes.dir}/org/opensolaris/opengrok"/>
1466N/A <propertyfile
1469N/A file="${build.classes.dir}/org/opensolaris/opengrok/info.properties">
1281N/A <entry key="version" value="${version}"/>
1281N/A <entry key="changeset" value="${changeset}"/>
1466N/A </propertyfile>
1281N/A </target>
1281N/A
1423N/A <property name="coverage.dir" value="${basedir}/coverage"/>
1281N/A <target name="-pre-compile" depends="jflex"/>
1281N/A <target name="-post-clean">
1281N/A <delete dir="${gensrcdir}"/>
1281N/A <delete file="${manifest.file}"/>
1281N/A <delete dir="${coverage.dir}"/>
1281N/A </target>
1281N/A
1281N/A <!--
1281N/A Create an empty manifest file so that nbproject/build-impl.xml
1423N/A notices that a manifest should be added to the jar file
1281N/A -->
1281N/A <target name="-touch-manifest">
1423N/A <!-- no attributes, main-class and class-path will be added later -->
1281N/A <manifest file="manifest.mf" mode="replace"/>
1281N/A </target>
1355N/A
1355N/A <target name="-pre-init" depends="-touch-manifest"/>
1281N/A
1355N/A <!--
1281N/A Initialize a property holding a list of jar files on which
1355N/A opengrok.jar depends
1469N/A -->
1466N/A <target name="-post-init">
1281N/A <pathconvert property="opengrok.lib.files" pathsep=" ">
1423N/A <path>
1281N/A <pathelement path="${javac.classpath}"/>
1281N/A </path>
1281N/A <flattenmapper/>
1281N/A <map from="" to="lib/"/>
1281N/A </pathconvert>
1281N/A </target>
1281N/A
1186N/A <!-- Update the manifest file with a classpath attribute -->
1186N/A <target name="-update-manifest-classpath">
1281N/A <manifest file="${manifest.file}" mode="update">
1281N/A <attribute name="Class-Path" value="${opengrok.lib.files}"/>
1186N/A </manifest>
1281N/A </target>
1186N/A
1186N/A <target name="-pre-jar" depends="-update-manifest-classpath,-update-build-info"/>
1186N/A
1281N/A <!--
1281N/A Copy the jars from lib to dist/lib manually if we don't have
0N/A the copylibs task from NetBeans
1186N/A -->
1186N/A <target name="-copy-lib-without-netbeans"
0N/A unless="manifest.available+main.class+mkdist.available">
1186N/A <copy todir="${dist.dir}/lib">
1186N/A <fileset file="${file.reference.ant.jar}"/>
1297N/A </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,svn-javahl.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 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/*"/>
</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 shortFilenames="true" targetjdk="1.6" failuresPropertyName="pmd.num.warnings">
<ruleset>rulesets/basic.xml</ruleset>
<ruleset>rulesets/braces.xml</ruleset>
<ruleset>rulesets/clone.xml</ruleset>
<ruleset>rulesets/design.xml</ruleset>
<ruleset>rulesets/favorites.xml</ruleset>
<ruleset>rulesets/finalizers.xml</ruleset>
<ruleset>rulesets/imports.xml</ruleset>
<ruleset>rulesets/junit.xml</ruleset>
<ruleset>rulesets/logging-java.xml</ruleset>
<ruleset>rulesets/migrating.xml</ruleset>
<!-- Enable when we have fever reported warnings -->
<!-- <ruleset>rulesets/optimizations.xml</ruleset> -->
<ruleset>rulesets/strictexception.xml</ruleset>
<ruleset>rulesets/strings.xml</ruleset>
<ruleset>rulesets/sunsecure.xml</ruleset>
<ruleset>rulesets/typeresolution.xml</ruleset>
<ruleset>rulesets/unusedcode.xml</ruleset>
<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.*"/>
</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"/>
<!-- Generate ZIP files used for unit testing -->
<zip destfile="${build.test.classes.dir}/org/opensolaris/opengrok/index/source.zip" basedir="testdata/sources"/>
<zip destfile="${build.test.classes.dir}/org/opensolaris/opengrok/history/repositories.zip" basedir="testdata/repositories"/>
</target>
<target name="emma-report" description="Analyze" depends="-check_emma">
<taskdef resource="emma_ant.properties" classpathref="emma.lib"/>
<emma enabled="true" >
<report sourcepath="src">
<!-- 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>
</project>