2016-12-14 69 views
1

我正在嘗試從生成exec文件生成XML jacoco報告,但ant正在拋出一個錯誤,它無法在jacocoant.jar中找到xml文件。在從jar中提取文件之後,文件就在那裏,並且已經在這個build.xml的其他用例中起作用。從命令ant -v -debug無法讀取Exec JaCoCo文件ANT

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  

回答

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

+0

有幫助!什麼導致exec文件的腐敗? –

+0

@StephenRaghunath取決於它是如何生成的。作爲示例之一 - JVM進程在將文件寫入磁盤過程中終止。當然也不排除任何常規文件的腐敗原因。 P.S.如果答案是有幫助的,那麼請不要忘記將它作爲正確答案/接受它。 – Godin

+0

謝謝你將繼續調查。 –

2

@Godin對堆棧跟蹤顯示的內容有正確的答案。要解決此問題,請執行下列操作:

JaCoCo在轉儲覆蓋率信息是異步任務時,將不會立即可用。文件可能需要一些時間才能完全寫入。因此,我們需要在創建這些exec文件的環境將它們上載到s3(10秒)之前自動執行適當的超時。

這是AWS Ec2實例的情況。