我有一個使用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