- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我对 Java 的 Checkstyle 插件有疑问。如果有任何违规行为,我需要让整个多模块项目失败。在父 pom.xml 我有以下内容
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ss.ita</groupId>
<artifactId>jresume</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>JResume</name>
<modules>
<module>common</module>
<module>persistence</module>
<module>business</module>
<module>logging</module>
<module>web</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.16</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>dev/checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我的 checkstyle.xml 放在 dev 文件夹中。
当我运行我的项目时
mvn clean install
它打印所有违规的列表。但它不能使整个项目失败。它为所有模块打印成功。我尝试同时使用 failsOnError 和 failOnViolation。但它没有用。 In plugin documentation 有这些要求:
我哪里出错了。也许我以错误的方式编写了我的 pom.xml。请帮我解决这个问题。
最佳答案
可能你忘记了
<configuration>
...
<violationSeverity>warning</violationSeverity>
...
</configuration>
violationSeverity
:被视为违规的最低严重性级别。有效值为“错误”、“警告”和“信息”。
默认值为error
,表示warning
不会使maven构建失败。
查看更多详细信息:
http://maven.apache.org/plugins/maven-checkstyle-plugin/check-mojo.html#violationSeverity
关于java - Maven 项目中的 Checkstyle。不能在违规的情况下使项目失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32461501/
发现一个类似的问题,关于 QAPlug-FindBugs 和 FindBugs-IDEA 之间的区别,但不是关于 CheckStyle... 我认为(根据以前的经验)这些插件的一个区别是 QAPlug
试图弄清楚我是否做错了什么,或者这是否是 maven checkstyle 插件中的错误。如果我执行 mvn checkstyle:check 我会得到这个: jonathanfisher@odin
我想确保我的代码不超过 5 级缩进,如下所示: class Foo { // 0 void bar() { // 1 if () { // 2 if (
FileTabCharacter检查似乎对我不起作用。下面是我的配置: .. .. .. .. .. .. 我有 XML 文件 - pom.xml和 checksty
有没有办法设置 checkstyle 来防止方法体中的前导、多个或尾随空行: 例如 private void a() { - int a = 1; doStuff(a); - - doMoreStuf
有没有办法设置 checkstyle 来防止方法体中的前导、多个或尾随空行: 例如 private void a() { - int a = 1; doStuff(a); - - doMoreStuf
我是 CheckStyle 等 Java 静态代码分析工具的新手。我下载了 Checkstyle 包并看到了 2 组检查: checkstyle_checks.xml sun_checks.xml。
我想使用//@checkstyle:off 和//@checkstyle:on 来免除代码的某些部分被 checkstyle 检查,但它仍然在提示。 public void invoke() {
我正在尝试将 import-control 添加到我们的 checkstyle 中,使 import-control 文件存在于制作 checstyle.xml 文件的项目中,而不是我们稍后构建的项目
我跑了mvn checkstyle:checkstyle ,但它没有使用我的自定义 checkstyle XML 文件。 请告诉我如何使用我自己的 checkstyle 文件而不是默认/现在配置的文件
执行命令mvn checkstyle:checkstyle时出现以下错误: An error has occurred in Checkstyle report generation. ... Cau
在我正在处理的一个项目中,我们有很多自定义 Checkstyle 检查。例如,我们使用 RegexpSingleline 模块排除所有类型的东西。我们的检查样式规则如下所示:
我正在使用 checkstyle获取有关我的源代码的报告。这个问题是关于MagicNumberCheck . 我正在使用 Date/(org.joda.)DateTime在我的源代码中是这样的: Da
我通过命令行上的 mvn 构建我的项目。 每当发生 checkStyle 错误时,我都会看到这种类型的输出: [ERROR] Failed to execute goal org.apache.mav
我有一个使用 Tycho 构建的 Eclipse 插件代码库。它使用在依赖 Artifact 中定义的父 POM,该 Artifact 指定 Checkstyle 配置的名称。 我还使用 checks
我是使用 Jenkins 的新手,我最近用它构建了一个项目并安装了“Checkstyle”插件并收到了一份报告。 我想知道如何配置“Checkstyle”以忽略空格或其他可能出现的标准? 谢谢! 最佳
我过去使用过检查样式,记得使用快捷键来应用检查样式修复(节省大量点击)。我不记得我是否为它设置了快捷方式,或者它是否已经附带了一个。 我的问题分为两部分:1)有没有一种简单的方法来检查是否有“Appl
我正在使用一个基本的 maven 项目,其中在 pom.xml 中只定义了以下内容: 依赖 javaee-api 依赖 junit 插件 maven-compile-plugin 插件 maven-w
我试图让 maven-checkstyle-plugin 对我们所有的项目使用相同的配置文件。 我尝试了几种方法,但没有一种是有效的。 唯一似乎有效的是当我将配置文件放在我的 maven 项目的根目录
我在 maven 构建中添加了 checkstyle 但由于某种原因它只检查 src/main 文件夹并忽略 src/test 文件夹,这是我的项目结构: Proj - Module A -
我是一名优秀的程序员,十分优秀!