<chapter id="findbugs_plugin">
    <title>The FindBugs Plugin</title>
    <para>The FindBugs plugin performs quality checks on your project's Java source files using <ulink url="http://findbugs.sourceforge.net">FindBugs</ulink>
        and generates reports from these checks.
    </para>

    <section>
        <title>Usage</title>
        <para>To use the FindBugs plugin, include the following in your build script:</para>
        <sample id="useFindBugsPlugin" dir="codeQuality" title="Using the FindBugs plugin">
            <sourcefile file="build.gradle" snippet="use-findbugs-plugin"/>
        </sample>
        <para>The plugin adds a number of tasks to the project that perform the quality checks. You can execute the checks by running <userinput>gradle check</userinput>.</para>
    </section>

    <section>
        <title>Tasks</title>
        <para>The FindBugs plugin adds the following tasks to the project:</para>
        <table>
            <title>FindBugs plugin - tasks</title>
            <thead>
                <tr>
                    <td>Task name</td>
                    <td>Depends on</td>
                    <td>Type</td>
                    <td>Description</td>
                </tr>
            </thead>
            <tr>
                <td>
                    <literal>findbugsMain</literal>
                </td>
                <td><literal>classes</literal></td>
                <td><apilink class="org.gradle.api.plugins.quality.FindBugs"/></td>
                <td>Runs FindBugs against the production Java source files.</td>
            </tr>
            <tr>
                <td>
                    <literal>findbugsTest</literal>
                </td>
                <td><literal>testClasses</literal></td>
                <td><apilink class="org.gradle.api.plugins.quality.FindBugs"/></td>
                <td>Runs FindBugs against the test Java source files.</td>
            </tr>
            <tr>
                <td>
                    <literal>findbugs<replaceable>SourceSet</replaceable></literal>
                </td>
                <td>
                    <literal><replaceable>sourceSet</replaceable>Classes</literal>
                </td>
                <td><apilink class="org.gradle.api.plugins.quality.FindBugs"/></td>
                <td>Runs FindBugs against the given source set's Java source files.</td>
            </tr>
        </table>

        <para>The FindBugs plugin adds the following dependencies to tasks defined by the Java plugin.</para>
        <table>
            <title>FindBugs plugin - additional task dependencies</title>
            <thead>
                <td>Task name</td>
                <td>Depends on</td>
            </thead>
            <tr>
                <td><literal>check</literal></td>
                <td>All FindBugs tasks, including <literal>findbugsMain</literal> and <literal>findbugsTest</literal>.</td>
            </tr>
        </table>
    </section>

    <section>
        <title>Dependency management</title>
        <para>The FindBugs plugin adds the following dependency configurations:</para>
        <table>
            <title>FindBugs plugin - dependency configurations</title>
            <thead>
                <tr>
                    <td>Name</td>
                    <td>Meaning</td>
                </tr>
            </thead>
            <tr>
                <td>
                    <filename>findbugs</filename>
                </td>
                <td>The FindBugs libraries to use</td>
            </tr>
        </table>
    </section>

    <section>
        <title>Configuration</title>
        <para>See the <apilink class="org.gradle.api.plugins.quality.FindBugsExtension"/> class in the API documentation.</para>
    </section>
</chapter>