我在 Jenkins 中配置 Cobertura 代码覆盖工具以使用混合 Java/Scala 项目时遇到困难。Java 类工作正常,但 Cobertura 不分析 Scala 测试。
我的 pom.xml 中的 Scala 特定配置:
<version.scala.plugin>3.1.0</version.scala.plugin>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<check/>
</configuration>
<version>2.5.2</version
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<!--suppress MavenModelInspection -->
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<!--suppress MavenModelInspection -->
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>