Groovy Maven Compilation fails with error: Unable to determine Groovy version. Is Groovy declared as a dependency?

Viewed 3458

I have a fairly vanilla groovy project that builds using maven. It utilises the gmavenplus plugin, with the pom lifted straight from the gmaven plus web page

pom looks something like this:

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>1.8.0</version>
        <executions>
          <execution>
            <goals>
              <goal>addSources</goal>
              <goal>addTestSources</goal>
              <goal>compile</goal>
              <goal>compileTests</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <!-- any version of Groovy \>= 1.5.0 should work here -->
      <version>2.5.8</version>
      <type>pom</type>
    </dependency>
  </dependencies>
</project>

When I build, I get the following error on the compile stage.

[INFO] --- gmavenplus-plugin:1.8:compile (default) @ myapp---
[INFO] Unable to get Groovy version from GroovySystem, trying InvokerHelper.
[WARNING] Unable to get Groovy version from InvokerHelper or GroovySystem, trying jar name.
[ERROR] Unable to determine Groovy version. Is Groovy declared as a dependency?

And the final maven error results in this:

[ERROR] Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.8:compile (default) on project myapp: Execution default of goal org.codehaus.gmavenplus:gmavenplus-plugin:1.8:compile failed. NullPointerException -> [Help 1]

I have tried all manner of tricks, hacks and cajoling to get it to compile. I actually got it working in Intellij by adding the groovy runtime as a direct module dependency (rather than a maven managed dependency), but this doesn't work from the command line.

I had previously had a similar setup working on gmaven plus 1.6 and groovy 2.4.7 on the same laptop, no idea why this is broken now.

1 Answers

So I eventually got it working properly by deleting the entire codehaus dir in the .m2 repo. Re-downloading everything seemed to sort it out and now it all works correctly without any hacks.

This github issue is somewhat related - https://github.com/groovy/GMavenPlus/issues/84 - and the final comment led me to zapping the repo.

Related