Generating a test-report crashes ant

220 views
Skip to first unread message

ders...@gmail.com

unread,
Sep 27, 2016, 4:05:38 PM9/27/16
to JaCoCo and EclEmma Users
Hello

I'm using the game "Freecol" http://www.freecol.org/ to make a coverage test with apache ant and JaCoCo.

I apologize in before hand if the formatting is off. I'm not sure how to properly format code here.

The stack trace/error message:
test-report:
parsing buildfile jar:file:/home/dersand/Downloads/freecol/jacoco/lib/jacocoant.jar!/org/jacoco/ant/antlib.xml with URI = jar:file:/home/dersand/Downloads/freecol/jacoco/lib/jacocoant.jar!/org/jacoco/ant/antlib.xml from a zip file
Trying to override old definition of task antlib:org.jacoco.ant:coverage
Trying to override old definition of task antlib:org.jacoco.ant:agent
Trying to override old definition of task antlib:org.jacoco.ant:report
Trying to override old definition of task antlib:org.jacoco.ant:merge
Trying to override old definition of task antlib:org.jacoco.ant:dump
Trying to override old definition of task antlib:org.jacoco.ant:instrument
[jacoco:report] Loading execution data file /home/dersand/Downloads/freecol/build/jacoco.exec

BUILD FAILED
/home/dersand/Downloads/freecol/build.xml:633: Error while creating report
at org.jacoco.ant.ReportTask.execute(ReportTask.java:501)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Caused by: java.io.IOException: Error while analyzing jars/standalone-compiler.jar@lib/substance.jar@org/jvnet/lafplugin/ComponentPluginManager.class.
at org.jacoco.core.analysis.Analyzer.analyzerError(Analyzer.java:155)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:130)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:147)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:185)
at org.jacoco.core.analysis.Analyzer.analyzeZip(Analyzer.java:257)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:188)
at org.jacoco.core.analysis.Analyzer.analyzeZip(Analyzer.java:257)
at org.jacoco.core.analysis.Analyzer.analyzeAll(Analyzer.java:188)
at org.jacoco.ant.ReportTask.createBundle(ReportTask.java:570)
at org.jacoco.ant.ReportTask.createReport(ReportTask.java:542)
at org.jacoco.ant.ReportTask.execute(ReportTask.java:495)
... 16 more
Caused by: java.lang.IllegalStateException: Can't add different class with same name: org/jvnet/lafplugin/ComponentPluginManager
at org.jacoco.core.analysis.CoverageBuilder.visitCoverage(CoverageBuilder.java:107)
at org.jacoco.core.analysis.Analyzer$1.visitEnd(Analyzer.java:96)
at org.jacoco.asm.ClassVisitor.visitEnd(ClassVisitor.java:317)
at org.jacoco.core.internal.flow.ClassProbesAdapter.visitEnd(ClassProbesAdapter.java:98)
at org.jacoco.asm.ClassReader.accept(ClassReader.java:697)
at org.jacoco.asm.ClassReader.accept(ClassReader.java:506)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:111)
at org.jacoco.core.analysis.Analyzer.analyzeClass(Analyzer.java:127)
... 25 more


This is what the build.xml looks like for the "test" target:
<target name="test" depends="build-unit-tests"
description="Runs a particular unit test">
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="jacoco/lib/jacocoant.jar"/>
</taskdef>

<jacoco:coverage destfile="${freecol.build.dir}/jacoco.exec" xmlns:jacoco="antlib:org.jacoco.ant">
<junit printsummary="yes" fork="true">
<classpath refid="test.run.classpath"/>
<formatter type="brief" usefile="false" />
<formatter type="plain" />
<test todir="${freecol.build.dir}" name="net.sf.freecol.${test}" />
<sysproperty key="java.awt.headless" value="true" />
</junit>
</jacoco:coverage>

<echo message="For more detailed information about this test run see:"/>
<echo message="${freecol.build.dir}/TEST-net.sf.freecol.${test}.txt"/>
</target>

test-report:
<target name="test-report" depends="test">
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="jacoco/lib/jacocoant.jar"/>
<classpath path="jacoco/lib/org.jacoco.report-0.7.7.201606060606.jar"/>
</taskdef>

<jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">
<executiondata>
<file file="${freecol.build.dir}/jacoco.exec" />
</executiondata>

<structure name="JaCoCo Ant Example">
<classfiles>
<fileset dir="${freecol.build.dir}" />
</classfiles>

<sourcefiles encoding="UTF-8">
<fileset dir="${freecol.src.dir}" />
</sourcefiles>
</structure>

<html destdir="${freecol.report.dir}/sample.html" />
<xml destfile="${freecol.report.dir}/report.xml"/>
</jacoco:report>

</target>

The following(relevant) file-structure:
freecol/
build/
src/
report/

Evgeny Mandrikov

unread,
Sep 28, 2016, 4:01:18 AM9/28/16
to JaCoCo and EclEmma Users, ders...@gmail.com
Hi,

Looking on innermost message of stack trace - "Can't add different class with same name: org/jvnet/lafplugin/ComponentPluginManager", I'm pretty sure that you need to exclude duplicates of class from report or put them into different group. See "Why do I get an error when I try to analyze multiple versions of the same class with a group?" at http://www.eclemma.org/jacoco/trunk/doc/classids.html

Best regards,
Evgeny
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages