我有一个使用 maven 构建的相当普通的 groovy 项目。它使用 gmavenplus 插件,pom 直接从 the gmaven plus web page 提取。
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>
当我构建时,在编译阶段出现以下错误。
[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?
最终的 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]
我尝试了各种技巧、黑客和哄骗来让它编译。实际上,我通过将 groovy 运行时添加为直接模块依赖项(而不是 maven 管理的依赖项)使其在 Intellij 中工作,但这在命令行中不起作用。
我以前在同一台笔记本电脑上有一个类似的设置,可以在 gmaven plus 1.6 和 groovy 2.4.7 上运行,不知道为什么现在坏了。
最佳答案
所以我最终通过删除 .m2 存储库中的整个 codehaus 目录使其正常工作。重新下载一切似乎解决了问题,现在一切正常,没有任何黑客攻击。
这个 github 问题有点相关 - https://github.com/groovy/GMavenPlus/issues/84 - 最后的评论让我放弃了 repo 协议(protocol)。
关于maven - Groovy Maven 编译失败,错误为 : Unable to determine Groovy version. Groovy 是否声明为依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58406695/