首页 > 解决方案 > maven-plugin-plugin:3.3:descriptor failed.: 更新 maven-core 时出现 RuntimeException

问题描述

我正在升级 maven 和一些过去可以工作的 maven 依赖项,但升级后我得到了 RuntimeException。

我已经从我的 maven 插件中删除了逻辑,所以它是纯 apache maven 代码而不是我自己的:

import org.apache.maven.lifecycle.mapping.LifecyclePhase;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;

@Mojo(name = "hello", requiresProject = true, defaultPhase = LifecyclePhase.PROCESS_RESOURCES)
public class HelloMojo extends AbstractMojo {

    public void execute() throws MojoExecutionException {
        System.out.println("Hello There!");
    }

}

我目前有以下工作正常的 pom 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>hello-maven-plugin</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>maven-plugin</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <!-- Changing this to 3.5.4 works -->
            <version>3.6.3</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

但是在执行 a 之后,mvn versions:use-latest-versions它会更新 maven-core,并且 3.6.0+ 版本的所有内容在执行 a 时都会导致以下错误mvn install

[INFO] --- maven-plugin-plugin:3.3:descriptor (default-descriptor) @ hello-maven-plugin ---
[WARNING] Using platform encoding (Cp1252 actually) to read mojo metadata, i.e. build is platform dependent!
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 0 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
[INFO] Applying mojo extractor for language: java-annotations
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.110 s
[INFO] Finished at: 2020-03-16T16:30:04-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor (default-descriptor) on project hello-maven-plugin: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor failed.: RuntimeException -> [Help 1]

升级到 maven core 3.6.3 时,我还需要更改什么吗?

标签: javamavenmaven-plugin

解决方案


推荐阅读