使用Java 8的cobertura-maven-plugin

时间:2014-09-02 16:14:03

标签: java maven cobertura maven-cobertura-plugin

只是我或者cobertura-maven-plugin不适用于java 8吗?当它运行时我得到了

[INFO] --- cobertura-maven-plugin:2.6:instrument (default) @ provider-impl ---
[INFO] Cobertura 2.0.3 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[cobertura] WARN  [main] net.sourceforge.cobertura.instrument.CoberturaInstrumenter - Unable to instrument file /var/lib/jenkins/workspace/BranchBuilder/implementations/provider-impl/target/generated-classes/cobertura/com/foo/impl/internal/ServiceProviderImpl$JoinRunner.class
java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:147)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.instrumentClass(CoberturaInstrumenter.java:121)
at net.sourceforge.cobertura.instrument.CoberturaInstrumenter.addInstrumentationToSingleClass(CoberturaInstrumenter.java:234)
at net.sourceforge.cobertura.instrument.Main.addInstrumentationToSingleClass(Main.java:298)
at net.sourceforge.cobertura.instrument.Main.addInstrumentation(Main.java:307)
at net.sourceforge.cobertura.instrument.Main.parseArguments(Main.java:399)

我知道ASM和java 8存在问题所以我怀疑问题是maven-plugin尚未更新为使用兼容java-8的ASM版本

作为参考,我问过问题here,但没有回答

有没有人设法在java 8中使用cobertura-maven-plugin?

3 个答案:

答案 0 :(得分:18)

我能够通过手动更新cobetura-maven-plugin使用的ASM依赖关系来实现它。这是一个包含更多细节的链接: http://www.befreeman.com/2014/09/getting-cobertura-code-coverage-with.html

答案 1 :(得分:6)

让它理解新的格式是一个悬而未决的问题,
https://github.com/mojohaus/cobertura-maven-plugin/issues/21

答案 2 :(得分:3)

如果您的<build><reporting>部分中有cobertura插件,也会发生这种情况。删除一个,问题就会消失。