Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-plugin-plugin:descriptor goal fails at the and of file

While developing a maven plugin the build prints error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor (default-descriptor) on project default-method-demo: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor failed: syntax error @[8,1] in file:/full/path/to/project/default-method/src/main/java/org/example/Iface.java -> [Help 1] 

even though that the file Iface.java is compilable.

Iface.java:

package org.example;  public interface Iface {     default String getString() {         return "string";     } } 

from pom.xml

<packaging>maven-plugin</packaging>  <build>     <plugins>         <plugin>             <groupId>org.apache.maven.plugins</groupId>             <artifactId>maven-compiler-plugin</artifactId>             <version>3.3</version>             <configuration>                 <source>1.8</source>                 <target>1.8</target>             </configuration>         </plugin>     </plugins> </build>  <dependencies>     <dependency>         <groupId>org.apache.maven</groupId>         <artifactId>maven-plugin-api</artifactId>         <version>3.0.5</version>     </dependency>     <dependency>         <groupId>org.apache.maven.plugin-tools</groupId>         <artifactId>maven-plugin-annotations</artifactId>         <version>3.4</version>         <scope>provided</scope>     </dependency> </dependencies> 

What causes the problem? How it can be fixed?

like image 785
czerny Avatar asked Jul 23 '16 23:07

czerny


1 Answers

The problem is that maven-plugin-plugin generating plugin descriptor had difficulties to parse Java 8 interfaces with default methods.

It can be fixed by explicitly stating newer plugin version in pom.xml:

<build>     <plugins>         <plugin>             <groupId>org.apache.maven.plugins</groupId>             <artifactId>maven-plugin-plugin</artifactId>             <version>3.4</version>         </plugin>         <!-- other plugins -->     </plugins> </build> 

Or just by avoiding default methods by moving their bodies to implementing classes.

Related bug: MPLUGIN-272

like image 177
czerny Avatar answered Sep 28 '22 09:09

czerny