【发布时间】:2012-06-21 20:02:00
【问题描述】:
一段时间以来,我一直在努力让 Checkstyle 在 Eclipse Indigo IDE 中的 Maven 中工作。最后,我想我会在这方面寻求一些专家的建议。
我正在使用 Eclipse Indigo 并尝试将 Checkstyle 配置为在 Maven 中运行。
下面是我的 pom.xml 的 sn-p。只有checkstyle:checkstyle 正在工作和创建报告。
<profile>
<id>checkstyle-profile</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>${basedir}/src/main/resources/maven_checks.xml</configLocation>
</configuration>
<executions>
<execution>
<id>checkstyle-check</id>
<goals>
<goal>check</goal>
</goals>
<phase>compile</phase> <!-- Default is "verify" -->
<configuration>
<violationSeverity>error</violationSeverity>
<maxAllowedViolations>7000</maxAllowedViolations>
<failOnViolation>true</failOnViolation>
<failsOnError>true</failsOnError>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>${basedir}/src/main/resources/maven_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</reporting>
一些不起作用的事情是:
- 自定义 checkstlye 的 configLocation 被忽略,始终默认为 Sun checkstlye。
- 我无法运行
checkstlye:check。我得到以下错误。我应该运行什么目标以便checkstyle:check运行。 未能在项目 zzz-web 上执行目标org.apache.maven.plugins:maven-checkstyle-plugin:2.9.1:check(default-cli):您有 5950 次 Checkstyle 违规 - 如果违规次数超过 7000,配置设置是否正确导致构建失败?
- Checkstyle 报告无法交叉引用报告中的 Java 代码。例如,如果我尝试从包向下钻取到 Java 类,然后单击违规的行号,它不会将我带到 Java 文件。也许我没有正确配置 jxr 插件。
希望尽快回复。
提前致谢。 瓦玛
【问题讨论】:
标签: maven checkstyle