java - Sonar + Clover 仅在 src-instrumented 上运行

标签 java maven sonarqube clover

目前我正在尝试进行集成测试 + Clover +Sonar 我可以这样做(我可以在 Sonar 中看到总覆盖范围,(IT + 单元测试)在一起) 问题在于,上传到 Sonar 的源代码是 clover 生成的用于执行其操作的源代码。

[INFO] [16:16:57.566] Working dir:/Users/cortiz/dev/company/tmp/profile/server/target/sonar
[INFO] [16:16:57.566] Source dirs:/Users/cortiz/dev/company/tmp/profile/server/target/clover/src-instrumented
[INFO] [16:16:57.566] Test dirs:/Users/cortiz/dev/company/tmp/profile/server/target/clover/src-test-instrumented
[INFO] [16:16:57.566] Binary dirs:/Users/cortiz/dev/company/tmp/profile/server/target/classes

或者周围有很多 __CLR** 的东西),所以源代码实际上不可读或不准确

我如何运行它是使用这个命令

mvn clean clover2:setup install clover2:clover sonar:sonar -PSonar

Sonar 配置文件是

    <profile>
        <id>Sonar</id>
        <properties>
            <clover.version>3.1.8</clover.version>
            <sonar.core.codeCoveragePlugin>clover</sonar.core.codeCoveragePlugin>
            <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
            <sonar.clover.reportPath>${project.build.directory}/clover.xml</sonar.clover.reportPath>
            <sonar.sources>bork</sonar.sources>
            <sonar.exclusions>**/clover/src-instrumented/**</sonar.exclusions>
        </properties>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.atlassian.maven.plugins</groupId>
                    <artifactId>maven-clover2-plugin</artifactId>
                    <version>${clover.version}</version>
                    <configuration>
                        <license>${clover.license}</license>
                        <reportDescriptor>clover-report.xml</reportDescriptor>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

如果需要,我可以提供更多信息。

最佳答案

DavidRACODON 建议

mvn clean clover2:setup install clover2:clover -PSonar 
mvn sonar:sonar -DskipTests -PSonar 

关于java - Sonar + Clover 仅在 src-instrumented 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18091664/

相关文章:

sonarqube - SonarCloud 要求对被 Istanbul 尔忽略的文件进行代码覆盖

jenkins - SonarQube 中未显示单元测试

eclipse - Maven install 命令不构建任何东西,但显示构建成功

java - 如何手动创建具有依赖项的 Java 应用程序

java - 在日志中显示 JAVA_OPTS 环境变量 我如何配置它?

java - 如何在 Java 上为网站创建漂亮的 URL(永久链接)?

Maven:我可以只将依赖项(没有应用程序)打包在 jar 中吗?

java - 我们应该如何验证正则表达式语法

java - Selenium 测试运行不会保存 cookie?

java - 访问数组列表中的对象(java)