mvn checkstyle:checkstyle 在使用报告时使用了错误的配置

mvn checkstyle:checkstyle uses wrong configuration when using reporting

我面临以下问题。我已经使用以下配置设置了我的检查样式:

<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>

这个运行我运行mvn site没问题。但是,当我通过 mvn checkstyle:checkstyle 运行 checkstyle 以便更有效地获取 XML 报告时,checkstyle 插件无法返回使用默认配置。当我将插件移至 <build> 时,XML 已正确生成,但现在生成的站点中不再包含 checkstyle 报告。

将报告插件设置为 Checkstyle 的 (current) 方法是什么,同时保留在相同配置下单独 运行 插件的能力?

它真的是定义插件和配置两次的首选方式吗?

好吧,显然你应该将带有配置的插件添加到 <build><reporting>