我有一个带有java和scala的多模块项目。Jenkins中安装了jacoco和scoverage插件,我希望在Jenkins中的单个构建作业中生成jacoco和scoverage报告(两者都是),但是只生成一个报告,要么是jacoco,要么是覆盖。
下面的mvn命令已经尝试过了-
mvn -B -s $MVN_SETTINGS jacoco:prepare-agent install scoverage:report jacoco:report
和
mvn -B -s $MVN_SETTINGS jacoco:prepare-agent install jacoco:report scoverage:report我的pom文件片段-
Plugins section -
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<destFile>./target/jacoco.exec</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<scalaVersion>2.10.4</scalaVersion>
<highlighting>true</highlighting>
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugins>
Reporting section -
<reporting>
<outputDirectory>${project.build.directory}/site</outputDirectory>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.3.0</version>
<configuration>
<aggregate>true</aggregate>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
</plugins>
</reporting>当我使用- mvn -B -s $MVN_SETTINGS jacoco:prepare-agent install scoverage:report jacoco:report
生成报告
建日志-
05:30:51编译05:30:51编译阅读覆盖率测量/workspace/Build-Pipeline/ABC/target/scoverage-data/scoverage.measurements.*... 05:30:51编译生成覆盖率报告05:30:51编译编写的Cobertura报告/workspace/Build-Pipeline/ABC/target/cobertura.xml 05:30:52编译编写的XML覆盖率报告/workspace/Build-Pipeline/ABC/target/scoverage.xml 05:30:53编译编写的HTML覆盖率报告/workspace/Build-Pipeline/ABC/target/site/scoverage/index.html 05:30:53编译语句覆盖率: 0.00% 05:30:53编译分支覆盖率.:0.00% 05:30:53编译覆盖报告完成。
当我用-
mvn -B -s $MVN_SETTINGS jacoco:prepare-agent install jacoco:report scoverage:report
覆盖率报告被生成
建日志-
05:15:07编译--覆盖范围-maven-plugin:1.3.0:report(默认-cli)@ ABC -- 05:15:07编译阅读覆盖工具/workspace/Build-Pipeline/ABC/target/scoverage-data/scoverage.coverage.xml...05:15:07编译阅读覆盖率测量/workspace/Build-Pipeline/ABC/target/scoverage-data/scoverage.measurements.*... 05:15:07编译生成覆盖率报告05:15:07编译编写的Cobertura报告/workspace/Build-Pipeline/ABC/target/cobertura.xml 05:15:08编译编写的XML覆盖率报告/workspace/Build-Pipeline/ABC/target/scoverage.xml 05:15:08编译书面HTML覆盖率报告/workspace/Build-Pipeline/ABC/target/site/scoverage/index.html 05:15:08编译语句覆盖率: 0.00% 05:15:08编译分支覆盖率.:0.00% 05:15:08编译覆盖报告完成。
有人能告诉我出了什么问题吗?
非常感谢
发布于 2019-01-15 16:18:35
给定src/main/java/HelloJava.java
class HelloJava {
public static String msg() {
return "Hello";
}
}src/main/scala/HelloScala.scala
object HelloScala {
def msg = {
"Hello"
}
}src/test/java/HelloTest.java
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class HelloTest {
@Test
public void test() {
assertEquals("Hello", HelloJava.msg());
assertEquals("Hello", HelloScala.msg());
}
}和pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.4</version>
<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.8.2</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.1.1</version>
<configuration>
<highlighting>true</highlighting>
</configuration>
</plugin>
</plugins>
</build>
</project>mvn clean test jacoco:report scoverage:report的执行
将产生target/site/jacoco/index.html

和target/site/scoverage/index.html

https://stackoverflow.com/questions/54185459
复制相似问题