Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过Maven命令行生成多种Cobertura报告格式_Java_Maven_Sonarqube_Cobertura_Maven Cobertura Plugin - Fatal编程技术网

Java 通过Maven命令行生成多种Cobertura报告格式

Java 通过Maven命令行生成多种Cobertura报告格式,java,maven,sonarqube,cobertura,maven-cobertura-plugin,Java,Maven,Sonarqube,Cobertura,Maven Cobertura Plugin,有了Maven,我可以通过改变POM的reporting部分,使用Cobertura生成多种不同类型的代码覆盖率报告 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <configuration> <formats>

有了Maven,我可以通过改变POM的reporting部分,使用Cobertura生成多种不同类型的代码覆盖率报告

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <configuration>
        <formats>
            <format>html</format>
            <format>xml</format>
        </formats>
    </configuration>
</plugin>
如何从Maven命令行生成多种不同的报告类型?

显然,我只能做一件事。。。我在下面试过了,但它不起作用

mvn clean cobertura:cobertura -Dcobertura.report.formats=xml,html
(注意:上面的属性使用“formats”而不是“format”。上面的属性总是创建默认的HTML报告,而不查看两种指定的格式。我使用的是Maven 3.2.3和Cobertura插件版本2.0.3。)


请帮帮我,我的咕咕咕噜咕噜不及格。。。有人知道这是否可行吗?

看起来不可能

从Sonatype博客帖子:

最新的Maven版本最终允许插件用户进行配置 从命令行通过逗号分隔的集合或数组 字符串

希望启用基于CLI的配置的插件作者 数组/集合只需要将表达式标记添加到它们的 参数注释

但在以下方面:

正如您所看到的,
格式
没有
表达式
标记(与
格式
不同),因此无法从命令行对其进行配置

更新 我刚刚意识到我回答了错误的问题:)我回答的问题是“如何使用“格式”选项从Maven命令行生成多种不同的报告类型?”。但最初的问题是“如何从Maven命令行生成多种不同的报告类型?”

实际上,有一个简单的解决方法-运行maven两次(第二次不使用
clean
),如下所示:

mvn clean cobertura:cobertura -Dcobertura.report.format=xml
mvn cobertura:cobertura -Dcobertura.report.format=html

谢谢,这就对了。奇怪的是,格式被标记为“不推荐”,但格式不是活动的。这是一个很好的解决方法,但对于像Jenkins这样的构建系统来说,执行两次分析不是很有效。无论如何,第一个答案抓住了我问题的要点。谢谢
/**
 * The format of the report. (supports 'html' or 'xml'. defaults to 'html')
 * 
 * @parameter expression="${cobertura.report.format}"
 * @deprecated
 */
private String format;

/**
 * The format of the report. (can be 'html' and/or 'xml'. defaults to 'html')
 * 
 * @parameter
 */
private String[] formats = new String[] { "html" };
mvn clean cobertura:cobertura -Dcobertura.report.format=xml
mvn cobertura:cobertura -Dcobertura.report.format=html