views:

352

answers:

1

Hi, I have a case where I want to run the cobertura plugin in both the verify phase and the reporting phase. I have two profiles and they should both be running the cobertura plugin, but in profile A, I only want to create the xml/html output, but in profile B, I will be generating full site documentation that includes these results.

I have cobertura configured as a plugin that runs as part of the verify phase, but if I do that, even if I run mvn verify site, the cobertura report does not appear in the site documentation. It seems as though I need to have it listed in both the plugins and the reporting section (since I won't be running site in profile A, it won't get called in that profile if I only have it in the plugins). So far the plugins section of my POM includes:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin </artifactId>
<version>2.2</version>
<configuration>
 <instrumentation>
  <excludes>
   <exclude>com/somepkg/**</exclude>
  </excludes>
 </instrumentation>
 <formats>
  <format>xml</format>
  <format>html</format>
 </formats>
</configuration>  
<executions>
 <execution>
  <phase>verify</phase>
  <goals>
   <goal>cobertura</goal>
  </goals>
 </execution>
</executions>
</plugin>

I don't want to copy this into the reporting section too since this is a lot to duplicate. Is there a good way to accomplish this otherwise?

Thanks,

Jeff

+4  A: 

Define this:

<executions>
        <execution>
                <phase>verify</phase>
                <goals>
                        <goal>cobertura</goal>
                </goals>
        </execution>
        <execution>
                <phase>pre-site</phase>
                <goals>
                        <goal>cobertura</goal>
                </goals>
        </execution>
</executions>
David Rabinowitz
thanks for the help.
Jeff Storey
On second look, does maven have a phase called reporting? http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference. It doesn't seem to be working as I expected...
Jeff Storey
Correct, as far as I know it is reporting are happening in the site generation
David Rabinowitz
I've found that if I just put the plugins in the reporting section and in my other build, I just run the goals from the command line it works best. The only problem is that I can't seem to specify the version to use when I execute from the command line. I was hoping it would pick it up from the reporting plugings, but it doesn't. Any way around this?
Jeff Storey
FYI - I've created properties to manage the version. I still need to list the plugins in both places (plugins and reporting), but the configurations are automatically pulled from the reporting section, but the versions are not. So I list the plugin groupId, artifactId, and version in both places (and version is a property)
Jeff Storey