Error creating code coverage report with JaCoCo
I once faced this problem as well. It seems to be related to the Jacoco analyzer not being able to parse some resources (that were presumably the git submodules or a zip/binary within them). Simply ignoring that path of the resources folder for this task fixed the problem.
See: https://github.com/devhub-tud/devhub/commit/c21607d753fbac1ba26e8b14d4ba84f4487620f8
And: https://github.com/devhub-tud/devhub/tree/master/src/main/resources/static
dty
Updated on June 20, 2022Comments
-
dty almost 2 years
I'm trying to add report generation for code coverage using JaCoCo. The project is using Maven, so i have jacoco maven plugin configured like this:
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.maven.plugin.version}</version> <executions> <execution> <id>prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile> </configuration> </execution> <execution> <id>report</id> <phase>prepare-package</phase> <goals> <goal>report</goal> </goals> <configuration> <dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile> <outputDirectory>${basedir}/target/jacoco</outputDirectory> </configuration> </execution> </executions> </plugin>
And surefire plugin like this:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${maven.surefire.plugin.version}</version> <configuration> <argLine>${argLine} -XX:-UseSplitVerifier</argLine> <printSummary>true</printSummary> <excludes> <exclude>**/selenium/**/*.java</exclude> <excludes> </configuration> </plugin>
But in the end of running
mvn clean package
i'm getting such error:
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.5.201505241946:report (report) on project LMS: An error has occurred in JaCoCo Test report generation. Error while creating report: invalid literal/length code -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The thing is, on another project same thing works like a charm. I couldn't find a solution online. Anyone has any ideas?
Using -e switch i get the following errors:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.5.201505241946:report (report) on project LMS: An error has occurred in JaCoCo Test report generation. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: An error has occurred in JaCoCo Test report generation. at org.jacoco.maven.AbstractReportMojo.execute(AbstractReportMojo.java:180) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more Caused by: org.apache.maven.reporting.MavenReportException: Error while creating report: invalid literal/length code at org.jacoco.maven.AbstractReportMojo.executeReport(AbstractReportMojo.java:196) at org.jacoco.maven.AbstractReportMojo.execute(AbstractReportMojo.java:178) ... 22 more Caused by: java.util.zip.ZipException: invalid literal/length code at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:164) at java.util.zip.ZipInputStream.read(ZipInputStream.java:193) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read(BufferedInputStream.java:254) at org.jacoco.core.internal.ContentTypeDetector.readInt(ContentTypeDetector.java:95) at org.jacoco.core.internal.ContentTypeDetector.determineType(ContentTypeDetector.java:68) at org.jacoco.core.internal.ContentTypeDetector.<init>(ContentTypeDetector.java:63) at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:172) at org.jacoco.core.analysis.Analyzer.analyzeZip(Analyzer.java:246) at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:178) at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:208) at org.jacoco.maven.BundleCreator.createBundle(BundleCreator.java:78) at org.jacoco.maven.AbstractReportMojo.createReport(AbstractReportMojo.java:219) at org.jacoco.maven.AbstractReportMojo.executeReport(AbstractReportMojo.java:193) ... 23 more