带有 Java 8 的 cobertura-maven-plugin

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25627884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 08:21:11  来源:igfitidea点击:

cobertura-maven-plugin with Java 8

javamavencoberturamaven-cobertura-plugin

提问by Hilikus

Is it just me or the cobertura-maven-plugin doesn't work with java 8? when it runs I get

是我还是 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)

I know there were issues with ASM and java 8 so I suspect the issue is that the maven-plugin has not been updated to use a java-8 compatible version of ASM

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

For reference, I asked the question herebut got no answer

作为参考,我在这里问了这个问题但没有得到答案

Has anyone managed to use cobertura-maven-plugin with java 8?

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

采纳答案by Jigar Joshi

It is an open issue to make it understand new classformat ,
https://github.com/mojohaus/cobertura-maven-plugin/issues/21

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

回答by Brian F

I was able to get it working by manually updating the ASM dependency used by the cobetura-maven-plugin. Here is a link with more details: http://www.befreeman.com/2014/09/getting-cobertura-code-coverage-with.html

我能够通过手动更新 cobetura-maven-plugin 使用的 ASM 依赖项来使其工作。这是包含更多详细信息的链接:http: //www.befreeman.com/2014/09/getting-cobertura-code-coverage-with.html

回答by RonanOD

This also happens if you have a cobertura plugin in your <build>and <reporting>sections. Remove one and the problem will go away.

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