findbugs Pmd CheckStyle Cobertura的Maven声纳插件配置 [英] Maven sonar plugin configurations for findbugs pmd checkstyle cobertura
问题描述
在为Maven项目设置代码质量插件方面,我需要一些帮助.
我有一个多模块项目.虽然在构建过程中配置了pmd
,checkstyle
,findbugs
和cobertura
,并且可以为每个插件生成xml报告,但是在我的项目中配置声纳插件时,我面临一些挑战.
I need some help in setting up code quality plugin for maven project.
I have a multi module project. While I have configured pmd
, checkstyle
, findbugs
and cobertura
in my build process, and I can generate xml reports for each plugin, I am facing some challenges configuring the sonar plugin in my project.
我不确定如何解决此问题:
I am not sure how to approach this problem:
- 在执行声纳时,我应该重用这些插件生成的报告吗?如果可以,我的声纳插件配置应该是什么?
- 如果我使用嵌入式
pmd
,checkstyle
,findbugs
和cobertura
插件运行声纳,如何配置它们以仅针对特定程序包运行,或者使findbugs
在com.mycompany.-
结构上进行分析. /li> - 过去,无论是在声纳外部还是在声纳内部运行cobertura,我都无法在声纳中获得覆盖率报告.
- Should I reuse the reports generated by these plugins while executing sonar? if so what should my sonar plugin configuration be?
- If I run sonar with embedded
pmd
,checkstyle
,findbugs
andcobertura
plugins, how do I configure them to run only for specific packages or makefindbugs
analyze oncom.mycompany.-
structure. - Lastly I cannot get coverage report in sonar, either running cobertura external to sonar or within sonar.
我下面有pom供审核.任何帮助将不胜感激.
I have my pom below for review. Any help will be tremendously appreciated.
这是在我的根pom的build部分的plugins部分中:
This is in the plugins section of the build section in my root 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)我应该重用这些插件生成的报告,而 执行声纳?如果可以,我的声纳插件配置应该是什么?
1) should I reuse the reports generated by these plugins while executing sonar? if so what should my sonar plugin configuration be?
Sonar不提供机制来重用这些插件生成的报告.您可以通过质量配置文件来配置规则.
Sonar does not provide a mechansim to reuse reports generated by these plugins. You could configure the rules through the quality profiles.
2)如果我运行带有嵌入式pmd,checkstyle,findbugs和cobertura插件的声纳,如何将它们配置为仅针对特定程序包运行,或者使findbugs在"com.mycompany.-"结构上进行分析.
2) if I run sonar with embedded pmd, checkstyle, findbugs and cobertura plugins, how do I configure them to run only for specific packages or make findbugs analyze on "com.mycompany.-" structure.
Sonar Web UI允许您为findbugs过滤器指定排除对象.科贝图拉(Cobertura)也是如此.不确定pmd,checkstyle.
Sonar web UI allows you to specify the exclusion for your findbugs filters. Likewise for cobertura. Not sure about pmd, checkstyle.
3)最后,我无法在声纳中获得覆盖率报告,无论是在声纳外部还是在声纳内部运行cobertura.
3) lastly i cannot get coverage report in sonar, either running cobertura external to sonar or within sonar.
由于 jacoco是默认代码覆盖引擎,因此有可能.您可以按照说明运行mvn clean verify/install sonar:sonar
并查看它是否有效.
It could be possible due to jacoco being the default code coverage engine. You could run mvn clean verify/install sonar:sonar
as instructed and see if it works.
这篇关于findbugs Pmd CheckStyle Cobertura的Maven声纳插件配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!