我正在尝试从generate exec文件生成XML jacoco报告,但是ant
引发了一个错误,它无法在jacocoant.jar中找到xml文件。从jar中提取文件后,该文件就在那里,并且已经在此build.xml的其他用例中工作。
从命令ant -v -debug
52336 $ ant -v -debug
Apache Ant(TM) version 1.9.6 compiled on June 29 2015
Trying the default build file: build.xml
Buildfile: /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/build.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.8 in: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre
Detected OS: Mac OS X
Adding reference: ant.ComponentHelper
Setting ro project property: ant.file -> /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/build.xml
Setting ro project property: ant.file.type -> file
Adding reference: ant.projectHelper
Adding reference: ant.parsing.context
Adding reference: ant.targets
parsing buildfile /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/build.xml with URI = file:/Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/build.xml
Setting ro project property: ant.project.name -> product-43
Adding reference: product-43
Setting ro project property: ant.project.default-target -> rebuild
Setting ro project property: ant.file.product-43 -> /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/build.xml
Setting ro project property: ant.file.type.product-43 -> file
Project base dir set to: /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336
+Target:
+Target: clean
+Target: merge
+Target: report
+Target: rebuild
Adding reference: ant.LocalProperties
parsing buildfile jar:file:/usr/local/Cellar/ant/1.9.6/libexec/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/local/Cellar/ant/1.9.6/libexec/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Setting project property: result.dir -> /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/target
Setting project property: result.classes.dir -> /Users/stephenraghunath/Downloads/gceDist/jacoco-classes
Setting project property: result.report.dir -> /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/target/site/jacoco
Setting project property: result.exec.file -> /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco.exec
parsing buildfile jar:file:/Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar!/org/jacoco/ant/antlib.xml with URI = jar:file:/Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar!/org/jacoco/ant/antlib.xml from a zip file
Finding class org.jacoco.ant.CoverageTask
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/CoverageTask.class
Class org.apache.tools.ant.TaskContainer loaded from parent loader (parentFirst)
Finding class org.jacoco.ant.AbstractCoverageTask
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/AbstractCoverageTask.class
Class org.apache.tools.ant.Task loaded from parent loader (parentFirst)
Class org.jacoco.ant.AbstractCoverageTask loaded from ant loader (parentFirst)
Class org.jacoco.ant.CoverageTask loaded from ant loader (parentFirst)
Class java.lang.Object loaded from parent loader (parentFirst)
Class java.lang.Throwable loaded from parent loader (parentFirst)
Class java.io.IOException loaded from parent loader (parentFirst)
Class org.apache.tools.ant.BuildException loaded from parent loader (parentFirst)
Class java.util.Collection loaded from parent loader (parentFirst)
+Datatype antlib:org.jacoco.ant:coverage org.jacoco.ant.CoverageTask
Finding class org.jacoco.ant.AgentTask
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/AgentTask.class
Class org.jacoco.ant.AgentTask loaded from ant loader (parentFirst)
+Datatype antlib:org.jacoco.ant:agent org.jacoco.ant.AgentTask
Finding class org.jacoco.ant.ReportTask
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/ReportTask.class
Class org.jacoco.ant.ReportTask loaded from ant loader (parentFirst)
Finding class org.jacoco.core.analysis.ICoverageVisitor
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/analysis/ICoverageVisitor.class
Class org.jacoco.core.analysis.ICoverageVisitor loaded from ant loader (parentFirst)
Finding class org.jacoco.core.analysis.ICoverageNode
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/analysis/ICoverageNode.class
Class org.jacoco.core.analysis.ICoverageNode loaded from ant loader (parentFirst)
Finding class org.jacoco.report.ISourceFileLocator
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/report/ISourceFileLocator.class
Class org.jacoco.report.ISourceFileLocator loaded from ant loader (parentFirst)
Finding class org.jacoco.core.analysis.IBundleCoverage
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/analysis/IBundleCoverage.class
Class org.jacoco.core.analysis.IBundleCoverage loaded from ant loader (parentFirst)
Finding class org.jacoco.ant.ReportTask$SourceFilesElement
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/ReportTask$SourceFilesElement.class
Class org.apache.tools.ant.types.resources.Union loaded from parent loader (parentFirst)
Class org.jacoco.ant.ReportTask$SourceFilesElement loaded from ant loader (parentFirst)
Class java.util.Iterator loaded from parent loader (parentFirst)
Class java.util.List loaded from parent loader (parentFirst)
Finding class org.jacoco.report.IReportVisitor
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/report/IReportVisitor.class
Finding class org.jacoco.report.IReportGroupVisitor
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/report/IReportGroupVisitor.class
Class org.jacoco.report.IReportGroupVisitor loaded from ant loader (parentFirst)
Class org.jacoco.report.IReportVisitor loaded from ant loader (parentFirst)
+Datatype antlib:org.jacoco.ant:report org.jacoco.ant.ReportTask
Finding class org.jacoco.ant.MergeTask
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/MergeTask.class
Class org.jacoco.ant.MergeTask loaded from ant loader (parentFirst)
+Datatype antlib:org.jacoco.ant:merge org.jacoco.ant.MergeTask
Finding class org.jacoco.ant.DumpTask
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/DumpTask.class
Class org.jacoco.ant.DumpTask loaded from ant loader (parentFirst)
Finding class org.jacoco.core.tools.ExecDumpClient
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/tools/ExecDumpClient.class
Class org.jacoco.core.tools.ExecDumpClient loaded from ant loader (parentFirst)
Finding class org.jacoco.ant.DumpTask$1
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/DumpTask$1.class
Class org.jacoco.ant.DumpTask$1 loaded from ant loader (parentFirst)
+Datatype antlib:org.jacoco.ant:dump org.jacoco.ant.DumpTask
Finding class org.jacoco.ant.InstrumentTask
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/ant/InstrumentTask.class
Class org.jacoco.ant.InstrumentTask loaded from ant loader (parentFirst)
Class java.lang.Exception loaded from parent loader (parentFirst)
Class java.io.OutputStream loaded from parent loader (parentFirst)
Class java.io.FileOutputStream loaded from parent loader (parentFirst)
Finding class org.jacoco.core.runtime.IExecutionDataAccessorGenerator
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/runtime/IExecutionDataAccessorGenerator.class
Class org.jacoco.core.runtime.IExecutionDataAccessorGenerator loaded from ant loader (parentFirst)
+Datatype antlib:org.jacoco.ant:instrument org.jacoco.ant.InstrumentTask
Setting ro project property: ant.project.invoked-targets -> rebuild
Attempting to create object of type org.apache.tools.ant.helper.DefaultExecutor
Adding reference: ant.executor
Build sequence for target(s) `rebuild' is [clean, merge, report, rebuild]
Complete build sequence is [clean, merge, report, rebuild, ]
clean:
merge:
[antlib:org.jacoco.ant] Could not load definitions from resource org/jacoco/ant/antlib.xml. It could not be found.
Class org.apache.tools.ant.types.ResourceCollection loaded from parent loader (parentFirst)
Class java.io.File loaded from parent loader (parentFirst)
Finding class org.jacoco.core.tools.ExecFileLoader
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/tools/ExecFileLoader.class
Class org.jacoco.core.tools.ExecFileLoader loaded from ant loader (parentFirst)
Finding class org.jacoco.core.data.ISessionInfoVisitor
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/data/ISessionInfoVisitor.class
Class org.jacoco.core.data.ISessionInfoVisitor loaded from ant loader (parentFirst)
Finding class org.jacoco.core.data.IExecutionDataVisitor
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/data/IExecutionDataVisitor.class
Class org.jacoco.core.data.IExecutionDataVisitor loaded from ant loader (parentFirst)
Class java.io.BufferedOutputStream loaded from parent loader (parentFirst)
Class java.io.InputStream loaded from parent loader (parentFirst)
Class java.io.BufferedInputStream loaded from parent loader (parentFirst)
Class java.io.FileInputStream loaded from parent loader (parentFirst)
Finding class org.jacoco.core.data.SessionInfoStore
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/data/SessionInfoStore.class
Class org.jacoco.core.data.SessionInfoStore loaded from ant loader (parentFirst)
Class java.util.ArrayList loaded from parent loader (parentFirst)
Finding class org.jacoco.core.data.ExecutionDataStore
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/data/ExecutionDataStore.class
Class org.jacoco.core.data.ExecutionDataStore loaded from ant loader (parentFirst)
Class java.util.Map loaded from parent loader (parentFirst)
Class java.util.Set loaded from parent loader (parentFirst)
Class java.util.HashMap loaded from parent loader (parentFirst)
Class java.util.HashSet loaded from parent loader (parentFirst)
fileset: Setup scanner in dir /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336 with patternSet{ includes: [**/*.exec] excludes: [] }
Class org.apache.tools.ant.types.Resource loaded from parent loader (parentFirst)
Class java.lang.String loaded from parent loader (parentFirst)
[jacoco:merge] Loading execution data file /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/10001.exec
Finding class org.jacoco.core.data.ExecutionDataReader
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/data/ExecutionDataReader.class
Class org.jacoco.core.data.ExecutionDataReader loaded from ant loader (parentFirst)
Finding class org.jacoco.core.data.IncompatibleExecDataVersionException
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/data/IncompatibleExecDataVersionException.class
Class org.jacoco.core.data.IncompatibleExecDataVersionException loaded from ant loader (parentFirst)
Finding class org.jacoco.core.internal.data.CompactDataInput
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/internal/data/CompactDataInput.class
Class java.io.DataInputStream loaded from parent loader (parentFirst)
Class org.jacoco.core.internal.data.CompactDataInput loaded from ant loader (parentFirst)
Finding class org.jacoco.core.data.SessionInfo
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/data/SessionInfo.class
Class java.lang.Comparable loaded from parent loader (parentFirst)
Class org.jacoco.core.data.SessionInfo loaded from ant loader (parentFirst)
Class java.lang.IllegalArgumentException loaded from parent loader (parentFirst)
Finding class org.jacoco.core.data.ExecutionData
Loaded from /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/jacoco/lib/jacocoant.jar org/jacoco/core/data/ExecutionData.class
Class org.jacoco.core.data.ExecutionData loaded from ant loader (parentFirst)
Class java.lang.IllegalStateException loaded from parent loader (parentFirst)
Class java.lang.Long loaded from parent loader (parentFirst)
Class org.apache.tools.ant.util.FileUtils loaded from parent loader (parentFirst)
BUILD FAILED
/Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/build.xml:17: Unable to read /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/10001.exec
at org.jacoco.ant.MergeTask.load(MergeTask.java:87)
at org.jacoco.ant.MergeTask.execute(MergeTask.java:67)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
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:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:853)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.io.EOFException
at java.io.DataInputStream.readFully(DataInputStream.java:197)
at java.io.DataInputStream.readLong(DataInputStream.java:416)
at org.jacoco.core.data.ExecutionDataReader.readExecutionData(ExecutionDataReader.java:147)
at org.jacoco.core.data.ExecutionDataReader.readBlock(ExecutionDataReader.java:115)
at org.jacoco.core.data.ExecutionDataReader.read(ExecutionDataReader.java:92)
at org.jacoco.core.tools.ExecFileLoader.load(ExecFileLoader.java:59)
at org.jacoco.ant.MergeTask.load(MergeTask.java:85)
... 18 more
Total time: 0 seconds
答案 0 :(得分:2)
根据日志末尾的堆栈跟踪 - 这与jacocoant.jar
中的xml文件无关,MergeTask
失败:
BUILD FAILED
/Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/build.xml:17:
Unable to read /Users/stephenraghunath/Downloads/gceDist/jacoco-classes/df-coverage/exec/bundle/213864/52336/10001.exec
at org.jacoco.ant.MergeTask.load(MergeTask.java:87)
...
Caused by: java.io.EOFException
at java.io.DataInputStream.readFully(DataInputStream.java:197)
...
EOFException
表示失败原因 - 文件10001.exec
已损坏,请参阅https://github.com/jacoco/jacoco/pull/397
答案 1 :(得分:2)
虽然@Godin对堆栈跟踪显示的内容有正确的答案。要解决此问题,请执行以下操作:
转储覆盖信息时,JaCoCo是一个异步任务,并且不会立即可用。可能需要一些时间才能完全写入文件。因此,在创建这些exec文件的环境将它们上传到s3(10秒)之前,我们需要自动执行适当的超时。这是AWS Ec2实例的情况。