build.xml revision c084b1b18556ad5cc865212ee5005e89455b30b7
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen<?xml version="1.0" encoding="UTF-8"?>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<!--
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoCDDL HEADER START
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoThe contents of this file are subject to the terms of the
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders HatlenCommon Development and Distribution License (the "License").
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoYou may not use this file except in compliance with the License.
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoSee LICENSE.txt included in this distribution for the specific
30d2f45dd260208f0fb882dde134a249318524b9Lubos Koscolanguage governing permissions and limitations under the License.
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoWhen distributing Covered Code, include this CDDL HEADER in each
30d2f45dd260208f0fb882dde134a249318524b9Lubos Koscofile and include the License file at LICENSE.txt.
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoIf applicable, add the following below this CDDL HEADER, with the
30d2f45dd260208f0fb882dde134a249318524b9Lubos Koscofields enclosed by brackets "[]" replaced with your own identifying
30d2f45dd260208f0fb882dde134a249318524b9Lubos Koscoinformation: Portions Copyright [yyyy] [name of copyright owner]
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoCDDL HEADER END
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoCopyright 2007 Sun Microsystems, Inc. All rights reserved.
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoUse is subject to license terms.
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner-->
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco<project name="OpenGrok" default="jar" basedir=".">
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner <description>Builds, tests, and runs the project opengrok.</description>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner <import file="nbproject/build-impl.xml"/>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner <import file="nbproject/profiler-build-impl.xml"/> <!--
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner There exist several targets which are by default empty and which can be
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner used for execution of your tasks. These targets are usually executed
d2b27f3d647af6fca607f14cb9296cc61c64b5b7Knut Anders Hatlen before and after some main targets. They are:
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
d2b27f3d647af6fca607f14cb9296cc61c64b5b7Knut Anders Hatlen -pre-init: called before initialization of project properties
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner -post-init: called after initialization of project properties
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner -pre-compile: called before javac compilation
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner -post-compile: called after javac compilation
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -pre-compile-single: called before javac compilation of single file
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner -post-compile-single: called after javac compilation of single file
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -pre-compile-test: called before javac compilation of JUnit tests
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner -post-compile-test: called after javac compilation of JUnit tests
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -pre-compile-test-single: called before javac compilation of single JUnit test
a3b788c055cf0bcc9b1d31fcd37876fe04472ebeLubos Kosco -post-compile-test-single: called after javac compilation of single JUunit test
a3b788c055cf0bcc9b1d31fcd37876fe04472ebeLubos Kosco -pre-jar: called before JAR building
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -post-jar: called after JAR building
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -post-clean: called after cleaning build products
a3b788c055cf0bcc9b1d31fcd37876fe04472ebeLubos Kosco
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen (Targets beginning with '-' are not intended to be called on their own.)
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen Example of inserting an obfuscator after compilation could look like this:
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <target name="-post-compile">
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner <obfuscate>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <fileset dir="${build.classes.dir}"/>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen </obfuscate>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen </target>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen For list of available properties check the imported
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen nbproject/build-impl.xml file.
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen Another way to customize the build is by overriding existing main targets.
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen The targets of interest are:
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco -init-macrodef-javac: defines macro for javac compilation
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco -init-macrodef-junit: defines macro for junit execution
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -init-macrodef-debug: defines macro for class debugging
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -init-macrodef-java: defines macro for class execution
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -do-jar-with-manifest: JAR building (if you are using a manifest)
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -do-jar-without-manifest: JAR building (if you are not using a manifest)
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner run: execution of project
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen -javadoc-build: Javadoc generation
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco test-report: JUnit report generation
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner An example of overriding the target for project execution could look like this:
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner
5f48c9d7604b81d6840032692d7b0fdd74976343Lubos Kosco <target name="run" depends="opengrok-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
<property name="version" value="0.6.1"/>
<property name="distname" value="opengrok"/>
<available file="JFlex.jar" type="file" property="JFlex.present">
<filepath>
<pathelement path="${user.home}/.ant/lib"/>
<pathelement path="${java.class.path}"/>
<pathelement path="lib"/>
</filepath>
</available>
<fail unless="JFlex.present" message="Please download JFlex(http://jflex.de/) and put JFlex.jar it into /lib directory(or in ant classpath)."/>
<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/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}"/>
</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"/>
<!--
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}"/>
</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,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="findbugs" depends="dist" description="Runs Findbugs on the OpenGrok source code">
<fail message="Please install Findbugs in lib-directory to run Findbugs, see README.">
<condition>
<not>
<and>
<available file="lib/findbugs/lib/findbugs.jar"/>
<available file="lib/findbugs/lib/findbugs-ant.jar"/>
</and>
</not>
</condition>
</fail>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpath="lib/findbugs/lib/findbugs-ant.jar"/>
<mkdir dir="findbugs"/>
<findbugs projectname="OpenGrok" home="lib/findbugs" 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="emma-instrument" depends ="compile" description="Instruments the source code for Emma code coverage analysis">
<fail message="Please install emma.jar and emma_ant.jar in lib-directory to run Emma, see README.">
<condition>
<not>
<and>
<available file="lib/emma.jar"/>
<available file="lib/emma_ant.jar"/>
</and>
</not>
</condition>
</fail>
<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"/>
</target>
<target name="emma-report" description="Analyze ">
<fail message="Please install emma.jar and emma_ant.jar in lib-directory to run Emma, see README.">
<condition>
<not>
<and>
<available file="lib/emma.jar"/>
<available file="lib/emma_ant.jar"/>
</and>
</not>
</condition>
</fail>
<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>