Table of Contents
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.
To compile FindBugs from source, you will need the following:
Apache Ant, version 1.5 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 and PDF formats.
The Saxon XSLT Processor. The file saxon.jar should be in your CLASSPATH.
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-0.9.1-source.zip
If you intend to build the FindBugs documentation, you will need to modify the build.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 build.properties looks 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.61.0 # Set this to the directory where Saxon (http://saxon.sourceforge.net/) # is installed. saxon.home =${local.software.home}/java/saxon-6.5.2
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.
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:
This target compiles the code for FindBugs. It is the default target.
This target formats the documentation. (It also compiles some of the source code as a side-effect.)
This target compiles and runs the internal JUnit tests included in FindBugs. It will print an error message if any unit tests fail.
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
The Ant build script for FindBugs is set up such that after building the build target, the working directory is set up just like a binary distribution. So, the information about installing a binary distribution of FindBugs in Chapter 2, Installing and Running FindBugs applies to source distributions, too.