在Maven中实施代码样式

时间:2014-02-26 18:54:09

标签: java maven checkstyle

如何在Maven构建时强制执行代码样式检查?

特别是,我想配置两个Maven构建以使用这两个:

如何将我的Maven构建配置为在代码样式违规时失败?

1 个答案:

答案 0 :(得分:1)

在pom.xml中配置插件时,您应该能够设置failOnViolation。

Maven check style as a part of the build

修改

啊,我明白了...我知道,Maven不存在Google Code Style插件。我想我会考虑编写你自己的maven插件,它会做类似于checkstyle的插件。

https://maven.apache.org/guides/introduction/introduction-to-plugins.htmlhttps://maven.apache.org/plugins/maven-checkstyle-plugin/source-repository.html

编辑2:

我想另一个选择是找到一种方法将IntelliJ Codestyle xml转换为checkstyle xml,然后根据这些规则使用maven-checkstyle-plugin失败。