Groovy 在 Codehaus 关闭后安装 HTTPBuilder?

Groovy install HTTPBuilder now that Codehaus shutdown?

我是 groovy n00b 并尝试使用 http-builder,但网络上的所有示例都引用了相同的 @Grab 语句,但该语句不起作用。我想这是因为 codehaus.org 不再托管 groovy 东西了。我尝试从 github 下载源代码并使用 Maven 构建它,但构建失败。

我应该如何以及在哪里获得 groovy 的 httpbuilder?

我已经尝试过的事情:

中删除葡萄目录无效。

我从 this other post 那里得到了这个代码片段,但它对我也不起作用。

@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7' )

def http = new groovyx.net.http.HTTPBuilder('http://www.codehaus.org')
println http

这是 IntelliJ 控制台中的错误:

 /Users/kenny/Sites/inadaydevelopment.com/reports/fetch_windows_appstore_report.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes -- 
[download failed: xerces#xercesImpl;2.9.1!xercesImpl.jar, 
download failed: xml-apis#xml-apis;1.3.04!xml-apis.jar]

编辑 1:

从命令行尝试了运行,仍然是同样的错误信息。

在 IntelliJ 中尝试 grab artifacts,但也失败了:

我想知道它是否与 Mac 相关,还有宾果游戏。我将这个脚本上传到我的 CentOS 服务器,它 运行 很好。导致问题的原因与 MacOSX+groovy 有关。

这在 groovy 控制台和命令行中工作正常。

http-builder 项目托管在 Maven Central

Grab 实际上会使用 JCenter,但 JCenter 是 Maven Central 的镜像,所以这个解决方案有效。

不确定为什么你会在解析传递依赖时遇到问题...可能是因为你正在使用代理,例如...也可能是你对 Maven 或 Ivy 的设置...检查 Groovy Grapes 文档以查看您是否可能无意中配置了导致此问题的内容。

此外,尝试从 groovy控制台或命令行排除 IntelliJ 中的一些冲突。

在 IntelliJ 中,指向 Grab 注释并点击 Alt+Enter。然后 select grab artifactsEnter.

它应该可以工作(对我有用),你应该能够运行脚本没有问题。

如果它抱怨 Ivy 不在类路径中,只需将 Ivy 添加到模块依赖项中即可。

知道了!看起来问题出在 Maven 缓存上。

我找到了解决方案 on this page:

rm -rf ~/.m2/repository ~/.groovy/grapes

我之前曾尝试删除 ~/.groovy/grapes 缓存,但这并没有解决问题。删除 ~/.m2/repository 才是真正为我做的。