我需要一些帮助来为 Maven 项目设置代码质量插件。
我有一个多模块项目。虽然我已经配置了pmd
, checkstyle
, findbugs
and cobertura
在我的构建过程中,我可以为每个插件生成 xml 报告,但我在项目中配置声纳插件时面临一些挑战。
我不知道如何解决这个问题:
- 我应该在执行声纳时重用这些插件生成的报告吗?如果是这样,我的声纳插件配置应该是什么?
- 如果我运行嵌入式声纳
pmd
, checkstyle
, findbugs
and cobertura
插件,如何将它们配置为仅针对特定包运行或 makefindbugs
分析于com.mycompany.-
结构。
- 最后,无论是在声纳外部还是在声纳内部运行 cobertura,我都无法获得声纳的覆盖范围报告。
我在下面有我的 pom 供审查。任何帮助将不胜感激。
这是我的根 pom 中构建部分的插件部分:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<instrumentation>
<includes>
<include>com/mycompany/**/*.class</include>
</includes>
</instrumentation>
<formats>
<format>xml</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<sourceEncoding>utf-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.6</targetJdk>
<includes>
<include>com/mycompany/**/*.java</include>
</includes>
<excludeRoots>
<excludeRoot>target/generated-sources/*</excludeRoot>
</excludeRoots>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<onlyAnalyze>com.mycompany.-</onlyAnalyze>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<includes>com/mycompany/**/*.java</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
1)我应该重用这些插件生成的报告吗?
执行声纳?如果是这样,我的声纳插件配置应该是什么?
Sonar 不提供重用这些插件生成的报告的机制。您可以通过以下方式配置规则质量概况 http://docs.codehaus.org/display/SONAR/Quality+Profiles.
2)如果我运行带有嵌入式 pmd、checkstyle、findbugs 和 cobertura 插件的声纳,如何将它们配置为仅针对特定包运行或使 findbugs 在“com.mycompany.-”结构上进行分析。
Sonar Web UI 允许您指定 findbugs 过滤器的排除项。对于科伯特拉来说也是如此。不确定 pmd、checkstyle。
3)最后,无论是在声纳外部还是在声纳内部运行cobertura,我都无法获得声纳的覆盖范围报告。
这可能是由于jacoco 是默认的代码覆盖率引擎 http://jira.codehaus.org/browse/SONAR-3536。你可以跑mvn clean verify/install sonar:sonar
按照说明进行操作,看看是否有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)