无法将maven checkstyle插件集成到构建中
如果“checkstyle”检测到任何错误,我希望生成失败。 我提到和。我的pom.xml如下所示:无法将maven checkstyle插件集成到构建中,maven,checkstyle,Maven,Checkstyle,如果“checkstyle”检测到任何错误,我希望生成失败。 我提到和。我的pom.xml如下所示: <build> <pluginManagement> <plugins> ..... ..... <plugin> <groupId>org.apache.maven.plugins</groupId>
<build>
<pluginManagement>
<plugins>
.....
.....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.11</version>
<executions>
<execution>
<id>validate</id>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
<configuration>
<configLocation>config/sun_checks.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
.....
.....
org.apache.maven.plugins
maven checkstyle插件
2.11
验证
检查
验证
config/sun_checks.xml
UTF-8
真的
真的
假的
运行checkstyle:check报告源中的错误。但运行install成功了。我尝试绑定插件以验证、处理源代码和其他阶段。但是构建总是成功的。我缺少一些配置吗?在这种情况下,您不应该使用
pluginManagement
。
pluginManagement
是一种控制所有依赖项目的父级插件配置的方法。如果孩子(或项目本身)想要使用它,它应该将插件添加到构建/插件中:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<!-- no version required -->
</plugin>
</plugins>
</build>
org.apache.maven.plugins
maven checkstyle插件
在这种情况下,您不应该使用插件管理。
pluginManagement
是一种控制所有依赖项目的父级插件配置的方法。如果孩子(或项目本身)想要使用它,它应该将插件添加到构建/插件中:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<!-- no version required -->
</plugin>
</plugins>
</build>
org.apache.maven.plugins
maven checkstyle插件
谢谢!!将配置从插件管理中移出,效果良好。谢谢!!将配置从pluginmanagement中移出,效果良好。