9

While trying to compile my project using the Maven Gmaven plugin, the following error occurred:

[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. 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:

    <!-- 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>
Marty Pitt
  • 28,822
  • 36
  • 122
  • 195

4 Answers4

14

This is caused by a missing providerSelection element from the GMaven plugin definition.

The correct GMaven definition looks as follows:

        <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>
Marty Pitt
  • 28,822
  • 36
  • 122
  • 195
1

Your problem might be caused by the Java version. In that case I recommend to downgrade it from Java 17 to Java 8.

Yunnosch
  • 26,130
  • 9
  • 42
  • 54
dKucharczyk
  • 170
  • 1
  • 6
  • Please explain how to find out whether the java version is to blame. – Yunnosch Nov 15 '22 at 15:09
  • By default, I have Java 17, but I just started working on the older project without any docs, or intro. So with the brute force method, I start testing a few Java versions. That one was working for me. – dKucharczyk Nov 17 '22 at 08:55
  • You should [edit] that explanation into the answer itself. Try for [answer]. – Yunnosch Nov 17 '22 at 09:04
0

With a small modification to Marty's solution I was able to get it to work:

<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>
0

Same error I had in my project but after long diagnosis found that jar associated with below dependency was corrupted.

<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>1.8.5</version>
</dependency>
Pushkar
  • 727
  • 1
  • 7
  • 21