首页 文章

拥有Jacoco和Sonar的Maven 0%覆盖范围

提问于
浏览
3

我有一个使用maven(scala-maven-plugin)构建的scala项目(带有一些java文件) . 我们已经插入了jacoco代码覆盖(jacoco-maven-plugin),并且可以生成良好的scala代码覆盖率 . 我们可以在/ target中的典型位置看到html / csv报告,并且scala覆盖范围都很好 .

但是我们无法通过声纳获取代码覆盖率来处理scala文件 . 该插件运行并发送java覆盖,所以我知道它从jacoco输出中拾取了一些内容,但缺少scala覆盖 .

此外,如果我运行jacoco:检查目标作为构建的一部分,它在覆盖范围内失败,再次仅引用java覆盖作为总覆盖数字 . 这让我相信这个问题与我配置jacoco而不是声纳的方式有关 .

任何帮助赞赏 .

以下是pom的相关部分

<plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.1.3</version>
                <configuration>
                    <args>
                        <arg>-g:vars</arg>
                    </args>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.6.2.201302030002</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
           <!-- disable surefire -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.plugin.surefire.version}</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <!-- enable scalatest -->
            <plugin>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest-maven-plugin</artifactId>
                <version>1.0-M2</version>
                <executions>
                    <execution>
                        <id>test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                            <junitxml>.</junitxml>
                            <parallel>true</parallel>
                            <tagsToExclude>IntegrationTest</tagsToExclude>
                            <filereports>ScalaTestSuite.txt</filereports>
                        </configuration>
                    </execution>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                            <junitxml>.</junitxml>
                            <parallel>true</parallel>
                            <tagsToInclude>IntegrationTest</tagsToInclude>
                            <filereports>ScalaIntegrationTestSuite.txt</filereports>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.sonar</groupId>
                <artifactId>sonar-maven3-plugin</artifactId>
                <version>3.4.1</version>
            </plugin>




  <sonar.host.url>http://vltapp02:9000/</sonar.host.url>
    <sonar.jdbc.url>jdbc:h2:tcp://vltapp02:9092/sonar</sonar.jdbc.url>
    <sonar.language>java</sonar.language>
    <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
    <sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.surefire.reportsPath>target/surefire-reports</sonar.surefire.reportsPath>

1 回答

  • 0

    可能是jacoco /声纳检查源文件夹 . 在这种情况下,您应该尝试将scala源文件夹公开给其他插件(通过'add-source'目标):

    <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.1.3</version>
                <configuration>
                    <args>
                        <arg>-g:vars</arg>
                    </args>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    

相关问题