Emma Class x appears to be instrumented already
Review the “maven-emma-plugin” in pom.xml :
<project> //... <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>emma-maven-plugin</artifactId> <version>1.0-alpha-3</version> <inherited>true</inherited> <executions> <execution> <phase>process-classes</phase> <goals> <goal>instrument</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <inherited>true</inherited> <configuration> <forkMode>once</forkMode> <reportFormat>xml</reportFormat> <classesDirectory> ${project.build.directory}/generated-classes/emma/classes </classesDirectory> </configuration> </plugin> </plugins> </build> </project>
1. Problem
When I run the command mvn emma:emma to generate the code coverage report, it prompts x class is instrumented already?
Failed to execute goal org.codehaus.mojo:emma-maven-plugin:1.0-alpha-3:instrument (default-cli) on project MkyongEmma: Execution default-cli of goal org.codehaus.mojo:emma-maven-plugin:1.0-alpha-3:instrument failed: class [com.mkyongemma.config.xxx] appears to be instrumented already -> [Help 1]
Try to exclude the problem class x from the build, but other classes also hit the same instrumented already error?
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>emma-maven-plugin</artifactId> <version>1.0-alpha-3</version> <inherited>true</inherited> <executions> <execution> <phase>process-classes</phase> <configuration> <filters> <filter>-com.mkyongemma.config.*</filter> </filters> </configuration> <goals> <goal>instrument</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
2. Solution
The problem is, when you run the command mvn emma:emma directly, the command line “Emma plugin” is started and instrumented the classes, while the other “Emma plugin” which declared in the pom.xml build section, will be started next and try to instrument the classes again. The error message is coming from the second “Emma plugin”, which try to instrument an instrumented already class.
P.S Try to trace the process behind with the Maven debug command mvn -X emma:emma
To solve it :
Solution 1
Remove the “emma-maven-plugin” from your pom.xml build section. Try running mvn -X emma:emma again. It should work fine and generate the code coverage report at ${project}\target\site\emma\.
Solution 2
If you want to include the “emma-maven-plugin” in the build section, use mvn package instead, to avoid the “emma-maven-plugin” running 2 times.
mvn package
References
- Stackoverflow : How do I exclude classes from being instrumented by the maven-emma plugin
- How To Display Maven Plugin Goals And Parameters
- Emma Maven Plugin Official Page
- Wikipedia – Apache Maven
From:一号门
COMMENTS