添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
严肃的面包  ·  Git 的Auto ...·  2 年前    · 
喝醉的跑步机  ·  java classpath ...·  3 年前    · 

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account
  • Operating system: Ubuntu
  • Tool integration: Maven
  • Description of your use case: I use Jacoco on a project that holds jar files in target/classes . Those jar files are used to run a separate java application in a separate jVM.
  • Current Behaviour

    The report goal fails with:

    [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