简体   繁体   English

GMaven 构建失败并显示“遇到 API 不兼容”

[英]GMaven build fails with "An API incompatibility was encountered"

While trying to compile my project using the Maven Gmaven plugin, the following error occurred:尝试使用 Maven Gmaven插件编译我的项目时,出现以下错误:

[ERROR] Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.4:compile (default) on project concorde-web: Execution default of goal org.codehaus.gmaven:gmaven-plugin:1.4:compile failed: An API incompatibility was encountered while executing org.codehaus.gmaven:gmaven-plugin:1.4:compile: java.lang.NoSuchMethodError: org.codehaus.groovy.ast.ModuleNode.getStarImports()Ljava/util/List;

Googling suggests that this is because of multiple groovy versions ending up in my dependency chain.谷歌搜索表明这是因为多个 groovy 版本最终出现在我的依赖链中。 However, after checking the full dependency tree, I find that there is only one dependency in the full tree.但是,查看全量依赖树后,发现全量树中只有一个依赖。

Here's the excerpt of my pom.xml:这是我的 pom.xml 的摘录:

    <!-- Groovy dependencies -->
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>1.8.5</version>
    </dependency>
    <!-- ... snip ... -->

        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>generateTestStubs</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

This is caused by a missing providerSelection element from the GMaven plugin definition. 这是由GMaven插件定义中缺少providerSelection元素引起的。

The correct GMaven definition looks as follows: 正确的GMaven定义如下:

        <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>1.4</version>
            <configuration>
                <providerSelection>1.8</providerSelection>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>generateTestStubs</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Your problem might be caused by the Java version.您的问题可能是由 Java 版本引起的。 In that case I recommend to downgrade it from Java 17 to Java 8.在这种情况下,我建议将其从 Java 17 降级为 Java 8。

With a small modification to Marty's solution I was able to get it to work: 通过对Marty解决方案的一个小修改,我能够让它工作:

<plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.5</version>

        <executions>
            <execution>
                <configuration>
                    <providerSelection>2.0</providerSelection>
                </configuration>
                <goals>
                    <goal>generateStubs</goal>
                    <goal>compile</goal>
                    <goal>generateTestStubs</goal>
                    <goal>testCompile</goal>
                </goals>
            </execution>
        </executions>
</plugin>

Same error I had in my project but after long diagnosis found that jar associated with below dependency was corrupted. 我在我的项目中遇到的错误,但经过长时间的诊断后发现与以下依赖关系相关的jar已损坏。

<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>1.8.5</version>
</dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Maven 构建失败并出现错误:执行 com.cosium.code:git-code-format-maven-plugin 时遇到 API 不兼容 - Maven build fails with error: An API incompatibility was encountered while executing com.cosium.code:git-code-format-maven-plugin 由于 API 不兼容,无法构建 Maven - Fail to Maven Build due to an API incompatibility maven-release-plugin:2.5.1:perform failed: 执行时遇到 API 不兼容 - maven-release-plugin:2.5.1:perform failed: An API incompatibility was encountered while executing maven-help-plugin:2.1.1:effective-settings failed: 执行时遇到 API 不兼容 - maven-help-plugin:2.1.1:effective-settings failed: An API incompatibility was encountered while executing nexus-staging-maven-plugin:maven 部署失败:执行时遇到 API 不兼容 - nexus-staging-maven-plugin: maven deploy failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar 失败:执行时遇到 API 不兼容问题 - org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar failed: An API incompatibility was encountered while executing JavaFX maven插件和API不兼容 - JavaFX maven plugin and API incompatibility Maven CXF插件API不兼容 - Maven CXF plugin API incompatibility 执行 org.apache.maven.plugins:maven-shade-plugin:1.3.1:shade: java.lang.AbstractMethodError: null 时遇到 API 不兼容 - An API incompatibility was encountered while executing org.apache.maven.plugins:maven-shade-plugin:1.3.1:shade: java.lang.AbstractMethodError: null Thorntail-Examples / API不兼容 - Thorntail-Examples / API Incompatibility
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM