我有一个使用maven(scala-maven-plugin)构建的scala项目(带有一些java文件)。我们有jacoco插入代码覆盖(jacoco-maven-plugin),并生成良好的scala代码覆盖率。我们可以在/ target中的典型位置看到html/csv报告,并且scala覆盖范围都很好。Jacoco和Sonar的Maven 0%覆盖率
但是,我们无法使用声纳对代码进行覆盖,以在scala文件上工作。该插件运行并发送java覆盖,所以我知道它正在从jacoco输出中获取某些内容,但scala覆盖范围已丢失。
另外,如果我运行jacoco:检查目标作为构建的一部分,它会覆盖失败,再次仅引用java覆盖率作为总覆盖率数字。这让我相信这个问题与我配置雅可比而不是声纳的方式有关。
任何帮助表示赞赏。
这里是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>
您是否曾经找到过解决方案? – RubberDuck 2017-08-07 21:12:06
最后我写了https://github.com/scoverage/sbt-scoverage – monkjack 2017-08-10 23:57:25