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

w8rqjzmb  于 2022-11-21  发布在  Maven
关注(0)|答案(4)|浏览(197)

尝试使用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;
Google建议这是因为多个Groovy版本最终出现在我的依赖项链中,但是,在检查完整的依赖项树后,我发现完整的树中只有一个依赖项。
下面是我的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>
kqqjbcuj

kqqjbcuj1#

这是由于GMaven插件定义中缺少providerSelection元素造成的。
正确的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>
hs1ihplo

hs1ihplo2#

你的问题可能是由Java版本引起的。如果是这样的话,我建议把它从Java 17降级到Java 8。

x759pob2

x759pob23#

对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>
nwlqm0z1

nwlqm0z14#

同样的错误,我在我的项目,但经过长时间的诊断发现,与下面的依赖关系相关联的jar被损坏。

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

相关问题