Hi I'm hitting the following exception when running a JaCoCo coverage:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.5.8.201207111220</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Error while creating report: Can't add different class with same name: org/hamcrest/BaseDescription
java.lang.IllegalStateException: Can't add different class with same name: org/hamcrest/BaseDescription
at org.jacoco.core.analysis.CoverageBuilder.visitCoverage(CoverageBuilder.java:89)
at org.jacoco.core.analysis.Analyzer$1.visitEnd(Analyzer.java:79)
at org.objectweb.asm.ClassAdapter.visitEnd(Unknown Source)
at org.jacoco.core.internal.flow.ClassProbesAdapter.visitEnd(ClassProbesAdapter.java:128)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:94)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:115)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:155)
at org.jacoco.core.analysis.Analyzer.analyzeArchive(Analyzer.java:135)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:158)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:183)
at org.jacoco.maven.ReportMojo.createBundle(ReportMojo.java:280)
at org.jacoco.maven.ReportMojo.createReport(ReportMojo.java:256)
at org.jacoco.maven.ReportMojo.executeReport(ReportMojo.java:230)
at org.jacoco.maven.ReportMojo.execute(ReportMojo.java:208)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
There are two ways to avoid this:
1)Rename one of the duplicates: I've seen this problem quite often when it comes to maven projects. Even if those two classes are in two different modules, having same names for two different classes is not really a good idea.
2)Exclude one of them: Refer this SO thread for more information.