【问题标题】:Does cobertura maven plugin don't work with java8 Default Method declaration in interfaces?cobertura maven 插件是否不适用于接口中的 java8 默认方法声明?
【发布时间】:2016-10-11 14:59:56
【问题描述】:

我已经使用 java8 默认方法声明声明了我的接口:

public interface MyInterface {

    default String myMethod(String str) {
        //IMPLEMENTATION
    }
}

接下来,我执行了 maven 目标:

mvn cobertura:cobertura

日志显示错误是因为cobertura不支持java8默认方法声明:

[INFO] Executed tasks
[INFO]
[INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) < [cobertura]test @ extractor <<<
[INFO]
[INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) @ extractor ---
[INFO] Cobertura 2.1.1 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
[INFO] Cobertura: Loaded information on 134 classes.
[WARN] JavaNCSS got an error while parsing the java file <PATH_TO_MY_INTERFACE>\MyInterface.java
ParseException in STDIN
Last useful checkpoint: "path.to.my.class.MyInterface"
Encountered " "default" "default "" at line 10, column 9.
Was expecting one of:
    "abstract" ...
    "boolean" ...
    "byte" ...
    "char" ...
    "class" ...
    "double" ...
    "enum" ...
    "final" ...
    "float" ...
    "int" ...
    "interface" ...
    "long" ...
    "native" ...
    "private" ...
    "protected" ...
    "public" ...
    "short" ...
    "static" ...
    "strictfp" ...
    "synchronized" ...
    "transient" ...
    "void" ...
    "volatile" ...
    <IDENTIFIER> ...
    "}" ...
    ";" ...
    "@" ...
    "<" ...

我该如何解决?

【问题讨论】:

  • 显然,没有(真正的)对 Java 8 的支持。CHANGELOG 声称支持 2.1.1,但是有很多未解决的问题和线程报告问题......
  • 我建议使用 JaCoCo 而不是 cobertura,因为自 Java 6 以来不再需要检测......
  • 好吧 khmarbaise,我会试试 JaCoCo!

标签: java maven java-8 maven-cobertura-plugin


【解决方案1】:

我已更改为 JaCoCo maven 配置并且它工作正常。

JaCoCo Unit Tests + Reports

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-06
    • 1970-01-01
    • 1970-01-01
    • 2010-10-30
    • 2010-12-29
    • 2015-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多