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?

Upvotes: 8

Views: 798

Answers (1)

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

Upvotes: 4

Related Questions