Generating Multiple Cobertura Report Formats Via Maven Command Line
With Maven, I can generate several different types of code coverage reports with Cobertura by changing the reporting section of my POM, ala ...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
Alternatively, I can generate one type of report from the Maven command line, ala ...
mvn clean cobertura:cobertura -Dcobertura.report.format=xml
How do I create several different types of reports from the Maven command line?
Apparently I can only do this .... I tried it below and it doesn't work!
mvn clean cobertura:cobertura -Dcobertura.report.formats=xml,html
(NOTE: The above property uses "formats" versus "format". The above always creates a default HTML report without seeing the two formats specified. I am using Maven 3.2.3 and the Cobertura plugin version 2.0.3.)
Please help my googol fu not working .... does anyone know if this is possible or not?
source to share
It looks like it's impossible ...
From the Sonatype blog post Configuring plugins in Maven 3 :
The latest release of Maven finally allows plugin users to customize collections or arrays from the command line, separated by commas.
Plugin authors who want to include CLI based array / collection configuration just need to add an expression tag to their parameter annotation.
But in the plugin code :
/**
* 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" };
As you can see, formats
it has no tag expression
(unlike format
), so it cannot be configured from the command line.
Update
I just realized I answered the wrong question :) Question: "How can I generate several different types of reports from the Maven command line using the" formats "option ?". But the original question was, "How can I generate several different types of reports from the Maven command line?"
There is actually a simple workaround - start maven twice (second time without clean
), e.g .:
mvn clean cobertura:cobertura -Dcobertura.report.format=xml
mvn cobertura:cobertura -Dcobertura.report.format=html
source to share