Search code examples
javamavenjava-8maven-cobertura-plugin

Does cobertura maven plugin don't work with java8 Default Method declaration in interfaces?


I've declared my interface with java8 defult method declaration:

public interface MyInterface {

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

Next, i executed maven goal:

mvn cobertura:cobertura

The log shows error because cobertura does not support java8 default method declaration:

[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> ...
    "}" ...
    ";" ...
    "@" ...
    "<" ...

How can i fix it?


Solution

  • I've changed to JaCoCo maven configuration and it worked.

    JaCoCo Unit Tests + Reports