Plugin Information
This plugin allows you to capture code coverage report from Emma. Hudson will generate the trend report of coverage. Usage with Maven21. The Maven2 Emma plugin requires Maven >= 2.0.8 and Surefire >= 2.3. 2. Add the following to your POM file:
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<inherited>true</inherited>
<executions>
<execution>
<id>instrument</id>
<phase>pre-site</phase>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
<reporting>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<inherited>true</inherited>
</plugin>
...
</plugins>
</reporting>
3. Make sure the Surefire plugin configuration you have, to run your tests, has the following in it's configuration: <forkMode>always</forkMode> 4. You should add the following to your plugin repositories (either in your POM or in your settings.xml) to locate the Emma plugin:
<pluginRepositories>
...
<pluginRepository>
<id>snapshots.repository.codehaus.org</id>
<url>http://snapshots.repository.codehaus.org</url>
</pluginRepository>
...
</pluginRepositories>
5. Run the "site" goal in your build to generate Emma report. OutputThis will create target/site/emma/coverage.xml when you run mvn site, which can then be referenced by the Hudson plugin: Usage with ANT1. Create the taskdef and other necessary information for ANT: <property name="coverage.dir" value="${basedir}/coverage" /> <property name="emma.dir" value="/usr/bin/emma" /> <property name="src.dir" value="${basedir}/src/"/> <property name="class.dir" value="${basedir}/class/"/> <property name="instrumented.dir" value="${basedir}/inst/"/> <path id="emma.lib"> <fileset dir="${emma.dir}"> <include name="*.jar"/> </fileset> </path> <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> coverage.dir is the location emma will generate the report data to, and emma.dir should be the location of the emma binaries on your system. src.dir is the location of your source files, class.dir is the location of your binary files to be instrumented, and instrumented.dir is the location to store the instrumented binaries. <emma enabled="true"> <instr instrpath="${class.dir}" destdir="${instrumented.dir}" metadatafile="${coverage.dir}/metadata.emma" merge="true"> <filter excludes="au.com.jenisys.view.*"/> </instr> </emma> Use instrpathref instead of instrpath in conjunction with a previously-defined path for more complex setups. Use the filter nested element to include or exclude certain code from being instrumented. For more information on the instr element, see http://emma.sourceforge.net/reference/ch02s03.html 3. After the instrumented code has been run, tell emma how to prepare the reports: <emma enabled="true" > <report sourcepath="${src.dir}" > <fileset dir="${coverage.dir}" > <include name="*.emma" /> </fileset> <xml outfile="${coverage.dir}/coverage.xml" depth="method"/> </report> </emma> This will generate an xml report, to the method depth of detail. For more information on the report element, see http://emma.sourceforge.net/reference/ch02s04.html ChangelogVersion 1.10 (2009/6/9)
Version 1.9 (2009/4/6)
|


Comments (6)
Apr 03, 2009
Sarthak says:
Hi, Can we make the Emma plugin compatible with maven projects? Currently, I ca...Hi,
Can we make the Emma plugin compatible with maven projects? Currently, I cant add the emma plugin to my m2 projects. I dont want to use freestyle projects, since I lose all the maven features of dependency management.
Thanks
Apr 12, 2009
Frank says:
The coverage trend is useful, but I would really like to get Hudson to display t...The coverage trend is useful, but I would really like to get Hudson to display the detailed coverage report (available using the <html> element to the <report> element shown above). Could I achieve this by configuring the Sidebar-Link Plugin to point to a location in the build project's workspace?
May 06, 2009
Gary says:
I am trying to install this plugin on Hudson version 1.276. It looks to be insta...I am trying to install this plugin on Hudson version 1.276. It looks to be installed correctly but it does not appear in the list of installed plugins. I then tried to install to install the Sidebae-Link Plugin above and it does appear in the list of installed plugins.
Jun 10
Carolyn Teo says:
Hi I had 2 concerns about Emma : Emma was install in Hudson but the hel...Hi
I had 2 concerns about Emma :
Emma was install in Hudson but the help test does not seem to display properly.
It seems that Emma does not allow wildcard. Is this a possible addition to Emma?? Because there are individual modules that are build under emma and these generate different statistics. So we wanted to be able to capture them
Thanks!
Jul 14
Thomas Jonsson says:
Hi! How about this plugin and multi-module maven projects? I can't come up ...Hi!
How about this plugin and multi-module maven projects? I can't come up with any ideas how to get it to work. Does anyone know if it is possible to invoke post-build actions on a sub module in Hudson?
Best regards,
Thomas
Nov 16
Bruno Bonacci says:
I do agree with above Thomas and Carolyne comments. The plugin currently d...I do agree with above Thomas and Carolyne comments. The plugin currently doesn't support multi-module maven 2 projects (as you can specify only one coverage.xml).
The only way is building goal that merge all metadata files together and is pretty ugly and laborious. It would be nice if we can specify an ant fileset (*//coverage.e*).
thanks
Bruno