Emma Class x appears to be instrumented already

摘要: Review the “maven-emma-plugin” in pom.xml :

Review the “maven-emma-plugin” in pom.xml :

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?

pom.xml
<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

  1. Stackoverflow : How do I exclude classes from being instrumented by the maven-emma plugin
  2. How To Display Maven Plugin Goals And Parameters
  3. Emma Maven Plugin Official Page
  4. Wikipedia – Apache Maven

上一篇: Maven site build is very slow dependency report
下一篇: The type DefaultHttpClient is deprecated
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号