views:

342

answers:

1

hi,

I'm using the maven cobertura plugin to generate coverage reports, but for some reason, the instrument goal gets stuck in an infinite loop. In my classes directory (named bin), an infinite loop occurs and creates directories named generated-classes/cobertura/generated-classes/cobertura...and on and on as long as I let the instrument goal run. Inside each of the cobertura directories are my instrumented classes. Any idea why this might occur?

thanks,

Jeff

+1  A: 

Can you post your pom file? Or at least the relevant sections? You should have something like the following:

<build>
 <pluginManagement>
  <plugins>
...snip...     
   <!-- cobertura code coverage plugin -->
   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
     <formats>
      <format>xml</format>
     </formats>
    </configuration>
   </plugin>
   <!-- end cobertura code coverage plugin -->

        </plugins>
    </pluginManagement>
</build>

<reporting>
<plugins>
 <plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>cobertura-maven-plugin</artifactId>
  <version>2.2</version>
  <configuration>
   <formats>
    <format>xml</format>
   </formats>
  </configuration>
 </plugin>
</plugins>
</reporting>

Also, are you following the standard maven directory layout for your source? Where is your pom file with respect to your source files, and what does your directory layout look like?

mjd79
Hi. My POM section looks like yours. maven runs the cobertura task but it hangs up on cobertura:instrument. my directory structure is not the standard maven layout, particularly my output directory (it is bin instead of classes). do i need to specify that somewhere in cobertura?
Jeff Storey
I think the problem is that my default output directory is just bin, and not target/bin (or some second level). the plugin gets stuck in a recursive loop because it is placing its generated-classes directory at the same level as my actual instrumented classes. ill have to update that and see if it fixes the problem.
Jeff Storey
While it's not required, I would definitely recommend you setup your project according to the maven spec: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html - I realize it may not be possible for every project, but it's something to consider.I got hung up on that as well the first time I tried using maven, because I thought my directory organization was a bit more intutitive, but once you jump into the "convention-over-configuration" idea, everything just *works*. I'll dig around and see what else I can find though.
mjd79
I appreciate the help. Our company has a standard for their directory structure. I was easily able to configure the POM to work with that. Anyway, once I created an extra layer in my output dir (so target/bin instead of just bin), cobertura started working. Thanks again.
Jeff Storey