12
  1. org.sonatype.maven.plugin:emma-maven-plugin:1.2
  2. org.codehaus.mojo:emma-maven-plugin:1.0-alpha-3
  3. org.apache.maven.plugins:maven-emma-plugin:0.5
canolucas
  • 1,482
  • 1
  • 15
  • 32
Stewart
  • 17,616
  • 8
  • 52
  • 80

2 Answers2

17

Use jacoco - emma in no longer supported. Jacoco supports java 7.

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.5.6.201201232323</version>
  <executions>
    <execution>
      <id>jacoco-initialize</id>
      <phase>initialize</phase>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
    </execution>
    <execution>
      <id>jacoco-site</id>
      <phase>package</phase>
      <goals>
        <goal>report</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Mike Samuel
  • 118,113
  • 30
  • 216
  • 245
Andrzej Jozwik
  • 14,331
  • 3
  • 59
  • 68
  • It's a great suggestion, but I didn't mark it as the answer because it answers a slightly different question. JaCoCo looks promising, but still young. I notice you need an XSLT workaround to get it working with Hudson / Jenkins. https://issues.jenkins-ci.org/browse/JENKINS-10835 – Stewart Mar 02 '12 at 13:08
  • 3
    There is the reason that I started using sonar with jenkins. If you use jenkins do not add emma to your pom - just call emma:emma. – Andrzej Jozwik Mar 02 '12 at 13:16
  • 1
    http://www.petrikainulainen.net/programming/maven/creating-code-coverage-reports-for-unit-and-integration-tests-with-the-jacoco-maven-plugin/ has a good writeup on integrating org.jacoco. – Mike Samuel May 03 '15 at 13:08
2

I'm not sure which one is the best. I do know that there is hardly any documentation on the sonatype plugin (other than this blog). Also I think the apache one is rather old, so personally I would try the codehaus plugin.

THelper
  • 15,333
  • 6
  • 64
  • 104
  • 1
    Fair enough. Codehaus is what I've been using for a while now, but recently I've had classpath issues when running 'mvn site' ('mvn deploy' works just fine) where I wanted to specifically control the sequence of the dependencies. The Sonatype plugin didn't have that problem, but instead, I found it wasn't creating a .txt or .xml report, just a .html one (and wrong charset at that). My work around is to revert back to the Codehaus plugin, and configure my CI to run 'mvn site' in a separate profile to 'mvn deploy' (the classpath issue has to do with using dbdeploy for certain database tests) – Stewart Mar 02 '12 at 12:58