Chapter 3. Building FindBugs™ from Source
Prev |  | Next

# Chapter 3. Building FindBugs™ from Source

This chapter describes how to build FindBugs from source code. Unless you are interesting in modifying FindBugs, you will probably want to skip to the next chapter.

## 1. Prerequisites

To compile FindBugs from source, you will need the following:

- The FindBugs source distribution

- JDK 1.5.0 or later

- Apache Ant, version 1.6.3 or later

| Warning
The version of Ant included as `/usr/bin/ant` on Redhat Linux systems will not work for compiling FindBugs. We recommend you install a binary distribution of Ant downloaded from the Ant website. Make sure that when you run Ant your `JAVA_HOME` environment variable points to the directory in which you installed JDK 1.5 (or later).

If you want to be able to generate formatted versions of the FindBugs documentation, you will also need the following software:

- The DocBook XSL Stylesheets. These are required to convert the FindBugs manual into HTML format.

- The Saxon XSLT Processor. (Also required for converting the FindBugs manual to HTML.)

## 2. Extracting the Source Distribution

After you download the source distribution, you'll need to extract it into a working directory. A typical command to do this is:

    $ unzip findbugs-3.1.0-dev-20260221-UNKNOWN-source.zip

## 3. Modifying `local.properties`

If you intend to build the FindBugs documentation, you will need to modify the `local.properties` file used by the Ant `build.xml` file to build FindBugs. If you do not want to build the FindBugs documentation, then you can ignore this file.

The `local.properties` overrides definitions in the `build.properties` file. The `build.properties` file looks something like this:

    # User Configuration:
    # This section must be modified to reflect your system.

    local.software.home     =/export/home/daveho/linux

    # Set this to the directory containing the DocBook Modular XSL Stylesheets
    #  from http://docbook.sourceforge.net/projects/xsl/

    xsl.stylesheet.home     =${local.software.home}/docbook/docbook-xsl-1.71.1

    # Set this to the directory where Saxon (http://saxon.sourceforge.net/)
    # is installed.

    saxon.home              =${local.software.home}/java/saxon-6.5.5

The `xsl.stylesheet.home` property specifies the full path to the directory where you have installed the DocBook Modular XSL Stylesheets. You only need to specify this property if you will be generating the FindBugs documentation.

The `saxon.home` property is the full path to the directory where you installed the Saxon XSLT Processor. You only need to specify this property if you will be generating the FindBugs documentation.

## 4. Running Ant

Once you have extracted the source distribution, made sure that Ant is installed, modified `build.properties` (optional), and configured the tools (such as Saxon), you are ready to build FindBugs. Invoking Ant is a simple matter of running the command

    $ ant target

where `target` is one of the following:

build

  This target compiles the code for FindBugs. It is the default target.

docs

  This target formats the documentation. (It also compiles some of the source code as a side-effect.)

runjunit

  This target compiles and runs the internal JUnit tests included in FindBugs. It will print an error message if any unit tests fail.

bindist

  Builds a binary distribution of FindBugs. The target creates both `.zip` and `.tar.gz` archives.

After running an Ant command, you should see output similar to the following (after some other messages regarding the tasks that Ant is running):

    BUILD SUCCESSFUL
    Total time: 17 seconds

## 5. Running FindBugs™ from a source directory

The Ant build script for FindBugs is written such that after building the build target, the working directory is set up just like a binary distribution. So, the information about running FindBugs in Chapter 4, Running FindBugs™ applies to source distributions, too.

Prev |  | Next
Chapter 2. Installing FindBugs™ | Home | Chapter 4. Running FindBugs™