Skip to main content
Skip table of contents

Checkstyle Analysis Results

To show Checkstyle analysis results, print the Checkstyle result XML to the build log.

Using Checkstyle Command Line

Use the -f=xml flag to print out the Checkstle analysis into the build log. For example:

CODE
java -jar ./checkstyle-9.3-all.jar -c=/sun_checks.xml -f=xml src/main/java/

Using Maven Checkstyle

The Maven Checkstyle plugin doesn’t support printing the XML into the logs. Configure Checkstyle in Maven first:

XML
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>3.1.2</version>
    <executions>
        <execution>
            <id>validate</id>
            <phase>validate</phase>
            <goals>
                <goal>checkstyle</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Then print the generated target/checkstyle-result.xml file into the build log by a final task:

CODE
#!/bin/bash
cat ./target/checkstyle-result.xml || echo "No Checkstyle analytics generated"

Using Gradle Checkstyle

The Gradle Checkstyle plugin doesn’t support printing the XML into the logs. Instead print the generated ./build/reports/checkstyle/main.xml file into the build log by a final task:

CODE
#!/bin/bash
cat ./build/reports/checkstyle/main.xml  || echo "No Checkstyle analytics generated"

Using Checkstyle via other Build System

Typically the build system tool generate a Checkstyle report xml. Dump that to the console by a final task. For example:

CODE
#!/bin/bash
cat ./a-build-dir/checkstyle-result.xml || echo "No Checkstyle analytics generated"

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.