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

1

29

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?

Wrest answered 23/7, 2016 at 23:15 Comment(0)
W
60

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

Wrest answered 23/7, 2016 at 23:15 Comment(1)
Just putting this in the pluginManagement section was enough for me.Hyperaemia

© 2022 - 2024 — McMap. All rights reserved.