Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn checkstyle:checkstyle uses wrong configuration when using reporting

Im facing the following problem. I have set up my checkstyle with the following configuration:

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>${checkstyle.plugin.version}</version>
            <inherited/>
            <configuration>
                <configLocation>${basedir}/checkstyle.xml</configLocation>
                <includeTestSourceDirectory>true</includeTestSourceDirectory>
            </configuration>
        </plugin>
    </plugins>
</reporting>

This runs fine when I run mvn site. However, when I run checkstyle through mvn checkstyle:checkstyle in order to get the XML report much more efficiently, the checkstyle plugin fails back to use the default configuration. When I move the plugin to <build> the XML is generated properly, but now the checkstyle report is not included in the generated site anymore.

What is the (current) way of setting up report plugins as Checkstyle, while perserving the ability to run the plugin separately under the same configuration?

Is it really the preferred way to defined your plugins and configuration twice?

like image 688
Jan-Willem Gmelig Meyling Avatar asked May 26 '15 19:05

Jan-Willem Gmelig Meyling


People also ask

How do I check my Checkstyle violations?

To view to violation report, go to Window -> Show View -> Other, and search for Checkstyle. Options for Violations and Violations Chart should be displayed.

How do I create a Checkstyle report?

To generate the Checkstyle report as part of the Project Reports, add the Checkstyle Plugin in the <reporting> section of your pom. xml . Then, execute the site phase to generate the report.


1 Answers

Okay, apparently you should add the plugin with configuration to both <build> and <reporting>.

like image 60
Jan-Willem Gmelig Meyling Avatar answered Oct 23 '22 22:10

Jan-Willem Gmelig Meyling