Groovy Maven 编译失败并出现错误:无法确定 Groovy 版本。Groovy 是否被声明为依赖项?

str*_*y05 3 groovy maven

我有一个使用 Maven 构建的相当普通的常规项目。它利用 gmavenplus 插件,直接从gmaven plus 网页提取 pom

pom 看起来像这样:

<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>
Run Code Online (Sandbox Code Playgroud)

当我构建时,我在编译阶段收到以下错误。

[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?
Run Code Online (Sandbox Code Playgroud)

最终的 Maven 错误结果如下:

[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]
Run Code Online (Sandbox Code Playgroud)

我尝试了各种技巧、黑客和哄骗来让它编译。实际上,我通过将 groovy 运行时添加为直接模块依赖项(而不是 Maven 管理的依赖项)来使其在 Intellij 中工作,但这在命令行中不起作用。

我之前在同一台笔记本电脑上的 gmaven plus 1.6 和 groovy 2.4.7 上有过类似的设置,不知道为什么现在这个设置被破坏了。

str*_*y05 7

因此,我最终通过删除 .m2 存储库中的整个 codehaus 目录使其正常工作。重新下载一切似乎都解决了,现在一切正常,没有任何黑客攻击。

这个 github 问题有些相关 - https://github.com/groovy/GMavenPlus/issues/84 - 最后的评论让我放弃了 repo。