Example - Access via JMX

This example illustrates the step required to use the jacocotogo maven plugin to retrieve coverage information over JMX.

JaCoCo Java Agent Configuration

The JVM which you wish to obtain coverage metrics from must be instrumented at runtime via the JaCoCo Java Agent. Additionally the jmx option must be enabled to expose the JaCoCo MBean via JMX.

    -javaagent:[yourpath/]jacocoagent.jar=jmx=true

Further Instructions for configuring the JaCoCo java agent are available at: http://www.eclemma.org/jacoco/trunk/doc/agent.html.

Plugin Configuration

To retrieve coverage metrics from a remote JVM after integration tests have completed:

...
    <build>
        <plugins>
            <plugin>
                <groupId>org.helmetsrequired</groupId>
                <artifactId>jacocotogo-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <id>get_integration_test_coverage</id>
                        <phase>post-integration-test</phase>                        
                        <goals>
                            <goal>jmx</goal>
                        </goals>
                        <configuration>
                            <serviceURL>service:jmx:rmi:///jndi/rmi://myserver.mydomain.com:5000/jmxrmi</serviceURL>
                            <outputFile>mypath/jacoco.exec</outputFile>
                        </configuration?
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
        ...
    </build>
    ...