[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.7:report (default-cli) on project http:
An error has occurred in JaCoCo report generation. Error while creating report:
Error while analyzing /srv/data/jenkins/workspace/my-project/http/target/classes/openejb-client.jar.pack.gz@javax/xml/ws/EndpointReference.class.
Can't add different class with same name: javax/xml/ws/EndpointReference -> [Help 1]
Wanted Behaviour
As per #661 (comment), I understand that Jacoco Maven plugin only analyzes the content of target/classes. Classes stored in jars found in target/classes will never end up in the JVM classpath.
Therefore, I don't see any reason to let Jacoco scan for zip, gz or pack200 files in the context of the Maven plugin. In this context, I think that analysis should be limited to plain class files (out of any archive).
I guess that would mean allowing to pass a detector type filter to Analyzer.analyzeAll method:
public int analyzeAll(final InputStream input, final String location)
throws IOException {
final ContentTypeDetector detector;
try {
detector = new ContentTypeDetector(input);
} catch (final IOException e) {
throw analyzerError(location, e);
switch (detector.getType()) {
case ContentTypeDetector.CLASSFILE:
analyzeClass(detector.getInputStream(), location);
return 1;
case ContentTypeDetector.ZIPFILE:
return analyzeZip(detector.getInputStream(), location);
case ContentTypeDetector.GZFILE:
return analyzeGzip(detector.getInputStream(), location);
case ContentTypeDetector.PACK200FILE:
return analyzePack200(detector.getInputStream(), location);
default:
return 0;
Possible Workarounds
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<configuration>
<excludes>
<exclude>**/*.jar.pack.gz</exclude>
<exclude>**/*.jar.pack</exclude>
<exclude>**/*.jar</exclude>
<exclude>**/*.zip</exclude>
</excludes>
</configuration>
</plugin>
changed the title
Jacoco maven plugin should exclude zip, gz and pack200 file from analysis
Jacoco maven plugin should exclude zip, gz and pack200 files from analysis
Nov 16, 2021