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

    <section>
        <title>Usage</title>
        <para>To use the Checkstyle plugin, include in your build script:</para>
        <sample id="useCheckstylePlugin" dir="codeQuality" title="Using the Checkstyle plugin">
            <sourcefile file="build.gradle" snippet="use-checkstyle-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 Checkstyle plugin adds the following tasks to the project:</para>
        <table>
            <title>Checkstyle plugin - tasks</title>
            <thead>
                <tr>
                    <td>Task name</td>
                    <td>Depends on</td>
                    <td>Type</td>
                    <td>Description</td>
                </tr>
            </thead>
            <tr>
                <td>
                    <literal>checkstyleMain</literal>
                </td>
                <td><literal>classes</literal></td>
                <td><apilink class="org.gradle.api.plugins.quality.Checkstyle"/></td>
                <td>Runs Checkstyle against the production Java source files.</td>
            </tr>
            <tr>
                <td>
                    <literal>checkstyleTest</literal>
                </td>
                <td><literal>testClasses</literal></td>
                <td><apilink class="org.gradle.api.plugins.quality.Checkstyle"/></td>
                <td>Runs Checkstyle against the test Java source files.</td>
            </tr>
            <tr>
                <td>
                    <literal>checkstyle<replaceable>SourceSet</replaceable></literal>
                </td>
                <td><literal><replaceable>sourceSet</replaceable>Classes</literal></td>
                <td><apilink class="org.gradle.api.plugins.quality.Checkstyle"/></td>
                <td>Runs Checkstyle against the given source set's Java source files.</td>
            </tr>
        </table>

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

    <section>
        <title>Project layout</title>
        <para>The Checkstyle plugin expects the following project layout:</para>
        <table>
            <title>Checkstyle plugin - project layout</title>
            <thead>
                <tr>
                    <td>File</td>
                    <td>Meaning</td>
                </tr>
            </thead>
            <tr>
                <td>
                    <filename>config/checkstyle/checkstyle.xml</filename>
                </td>
                <td>Checkstyle configuration file</td>
            </tr>
        </table>
    </section>

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

    <section>
        <title>Configuration</title>
        <para>See <apilink class="org.gradle.api.plugins.quality.CheckstyleExtension"/>.</para>
    </section>

</chapter>