• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html><head>
2      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
3   <title>Chapter&nbsp;3.&nbsp;Building FindBugs&#8482; from Source</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="installing.html" title="Chapter&nbsp;2.&nbsp;Installing FindBugs&#8482;"><link rel="next" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;3.&nbsp;Building <span class="application">FindBugs</span>&#8482; from Source</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="installing.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="running.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;3.&nbsp;Building FindBugs&#8482; from Source"><div class="titlepage"><div><div><h2 class="title"><a name="building"></a>Chapter&nbsp;3.&nbsp;Building <span class="application">FindBugs</span>&#8482; from Source</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="building.html#d0e173">1. Prerequisites</a></span></dt><dt><span class="sect1"><a href="building.html#d0e262">2. Extracting the Source Distribution</a></span></dt><dt><span class="sect1"><a href="building.html#d0e275">3. Modifying <code class="filename">local.properties</code></a></span></dt><dt><span class="sect1"><a href="building.html#d0e333">4. Running <span class="application">Ant</span></a></span></dt><dt><span class="sect1"><a href="building.html#d0e427">5. Running <span class="application">FindBugs</span>&#8482; from a source directory</a></span></dt></dl></div><p>
4This chapter describes how to build <span class="application">FindBugs</span> from source code.  Unless you are
5interesting in modifying <span class="application">FindBugs</span>, you will probably want to skip to the
6<a class="link" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;">next chapter</a>.
7</p><div class="sect1" title="1.&nbsp;Prerequisites"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e173"></a>1.&nbsp;Prerequisites</h2></div></div></div><p>
8To compile <span class="application">FindBugs</span> from source, you will need the following:
9</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
10      The <a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/findbugs-2.0.3-source.zip?download" target="_top"><span class="application">FindBugs</span> source distribution</a>
11    </p></li><li class="listitem"><p>
12      <a class="ulink" href="http://java.sun.com/j2se/" target="_top">JDK 1.5.0 or later</a>
13    </p></li><li class="listitem"><p>
14      <a class="ulink" href="http://ant.apache.org/" target="_top">Apache <span class="application">Ant</span></a>, version 1.6.3 or later
15    </p></li></ul></div><p>
16</p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="warning.png"></td><th align="left">Warning</th></tr><tr><td align="left" valign="top"><p>
17        The version of <span class="application">Ant</span> included as <code class="filename">/usr/bin/ant</code> on
18        Redhat Linux systems will <span class="emphasis"><em>not</em></span> work for compiling
19        <span class="application">FindBugs</span>.  We recommend you install a binary distribution of <span class="application">Ant</span>
20        downloaded from the <a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span> website</a>.
21        Make sure that when you run <span class="application">Ant</span> your <em class="replaceable"><code>JAVA_HOME</code></em>
22        environment variable points to the directory in which you installed
23        JDK 1.5 (or later).
24    </p></td></tr></table></div><p>
25If you want to be able to generate formatted versions of the <span class="application">FindBugs</span> documentation,
26you will also need the following software:
27</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
28    The <a class="ulink" href="http://docbook.sourceforge.net/projects/xsl/index.html" target="_top">DocBook XSL Stylesheets</a>.
29    These are required to convert the <span class="application">FindBugs</span> manual into HTML format.
30    </p></li><li class="listitem"><p>
31      The <a class="ulink" href="http://saxon.sourceforge.net/" target="_top"><span class="application">Saxon</span> XSLT Processor</a>.
32      (Also required for converting the <span class="application">FindBugs</span> manual to HTML.)
33    </p></li></ul></div><p>
34</p></div><div class="sect1" title="2.&nbsp;Extracting the Source Distribution"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e262"></a>2.&nbsp;Extracting the Source Distribution</h2></div></div></div><p>
35After you download the source distribution, you'll need to extract it into
36a working directory.  A typical command to do this is:
37
38</p><pre class="screen">
39<code class="prompt">$ </code><span class="command"><strong>unzip findbugs-2.0.3-source.zip</strong></span>
40</pre><p>
41
42</p></div><div class="sect1" title="3.&nbsp;Modifying local.properties"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e275"></a>3.&nbsp;Modifying <code class="filename">local.properties</code></h2></div></div></div><p>
43If you intend to build the FindBugs documentation,
44you will need to modify the <code class="filename">local.properties</code> file
45used by the <a class="ulink" href="http://ant.apache.org/" target="_top"><span class="application">Ant</span></a>
46<code class="filename">build.xml</code> file to build <span class="application">FindBugs</span>.
47If you do not want to build the FindBugs documentation, then you
48can ignore this file.
49</p><p>
50The <code class="filename">local.properties</code> overrides definitions
51in the <code class="filename">build.properties</code> file.
52The <code class="filename">build.properties</code> file looks something like this:
53</p><pre class="programlisting">
54
55# User Configuration:
56# This section must be modified to reflect your system.
57
58local.software.home     =/export/home/daveho/linux
59
60# Set this to the directory containing the DocBook Modular XSL Stylesheets
61#  from http://docbook.sourceforge.net/projects/xsl/
62
63xsl.stylesheet.home     =${local.software.home}/docbook/docbook-xsl-1.71.1
64
65# Set this to the directory where Saxon (http://saxon.sourceforge.net/)
66# is installed.
67
68saxon.home              =${local.software.home}/java/saxon-6.5.5
69
70</pre><p>
71</p><p>
72The <code class="varname">xsl.stylesheet.home</code> property specifies the full
73path to the directory where you have installed the
74<a class="ulink" href="http://docbook.sourceforge.net/projects/xsl/" target="_top">DocBook Modular XSL
75Stylesheets</a>.  You only need to specify this property if you will be
76generating the <span class="application">FindBugs</span> documentation.
77</p><p>
78The <code class="varname">saxon.home</code> property is the full path to the
79directory where you installed the <a class="ulink" href="http://saxon.sourceforge.net/" target="_top"><span class="application">Saxon</span> XSLT Processor</a>.
80You only need to specify this property if you will be
81generating the <span class="application">FindBugs</span> documentation.
82</p></div><div class="sect1" title="4.&nbsp;Running Ant"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e333"></a>4.&nbsp;Running <span class="application">Ant</span></h2></div></div></div><p>
83Once you have extracted the source distribution,
84made sure that <span class="application">Ant</span> is installed,
85modified <code class="filename">build.properties</code> (optional),
86and configured the tools (such as <span class="application">Saxon</span>),
87you are ready to build <span class="application">FindBugs</span>.  Invoking <span class="application">Ant</span> is a simple matter
88of running the command
89</p><pre class="screen">
90<code class="prompt">$ </code><span class="command"><strong>ant <em class="replaceable"><code>target</code></em></strong></span>
91</pre><p>
92where <em class="replaceable"><code>target</code></em> is one of the following:
93</p><div class="variablelist"><dl><dt><span class="term"><span class="command"><strong>build</strong></span></span></dt><dd><p>
94         This target compiles the code for <span class="application">FindBugs</span>. It is the default target.
95       </p></dd><dt><span class="term"><span class="command"><strong>docs</strong></span></span></dt><dd><p>
96       This target formats the documentation.  (It also compiles some of
97       the source code as a side-effect.)
98       </p></dd><dt><span class="term"><span class="command"><strong>runjunit</strong></span></span></dt><dd><p>
99            This target compiles and runs the internal JUnit tests included
100            in <span class="application">FindBugs</span>.  It will print an error message if any unit
101            tests fail.
102        </p></dd><dt><span class="term"><span class="command"><strong>bindist</strong></span></span></dt><dd><p>
103            Builds a binary distribution of <span class="application">FindBugs</span>.
104            The target creates both <code class="filename">.zip</code> and
105            <code class="filename">.tar.gz</code> archives.
106        </p></dd></dl></div><p>
107</p><p>
108After running an <span class="application">Ant</span> command, you should see output similar to
109the following (after some other messages regarding the tasks that
110<span class="application">Ant</span> is running):
111</p><pre class="screen">
112<code class="computeroutput">
113BUILD SUCCESSFUL
114Total time: 17 seconds
115</code>
116</pre><p>
117</p></div><div class="sect1" title="5.&nbsp;Running FindBugs&#8482; from a source directory"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e427"></a>5.&nbsp;Running <span class="application">FindBugs</span>&#8482; from a source directory</h2></div></div></div><p>
118The <span class="application">Ant</span> build script for <span class="application">FindBugs</span> is written such that after
119building the <span class="command"><strong>build</strong></span> target, the working directory
120is set up just like a binary distribution.  So, the information about
121running <span class="application">FindBugs</span> in <a class="xref" href="running.html" title="Chapter&nbsp;4.&nbsp;Running FindBugs&#8482;">Chapter&nbsp;4, <i>Running <span class="application">FindBugs</span>&#8482;</i></a>
122applies to source distributions, too.
123</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="installing.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="running.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;2.&nbsp;Installing <span class="application">FindBugs</span>&#8482;&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;4.&nbsp;Running <span class="application">FindBugs</span>&#8482;</td></tr></table></div></body></html>