在开发 Maven 插件时,构建打印错误:
[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]
即使文件
Iface.java
是可编译的。Iface.java
:package org.example;
public interface Iface {
default String getString() {
return "string";
}
}
来自
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>
是什么导致了问题?如何修复?
最佳答案
问题是 maven-plugin-plugin
生成插件描述符很难用默认方法解析 Java 8 接口(interface)。
它可以通过在 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>
或者只是通过将它们的主体移动到实现类来避免默认方法。
相关错误:MPLUGIN-272
关于 maven 插件插件:descriptor goal fails at the and of file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38547239/