Groovy install HTTPBuilder now that Codehaus shutdown?

[亡魂溺海] 提交于 2019-12-23 17:03:18

问题


I'm a groovy n00b and trying to use http-builder, but ALL of the examples on the web just reference the same @Grab statement which doesn't work. I assume it is because codehaus.org isn't hosting groovy stuff anymore. I've tried downloading the source from github and building it with Maven, but the build fails.

How and where am I supposed to get httpbuilder for groovy?

Things I've already tried:

Deleting the grapes directory from this post didn't work.

I got this code snippet from this other post, but it doesn't work for me either.

@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

Here is the error in the IntelliJ console:

 /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]

EDIT 1:

Tried running it from the command line, still same error message.

Tried grab artifacts in IntelliJ, but that failed too:

I wondered if it was Mac related, and bingo. I uploaded this script to my CentOS server and it ran just fine. There is something related to MacOSX+groovy that is causing the problem.


回答1:


Got it! It looks like it was the maven cache that was the problem.

I found the solution on this page:

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

I had previously tried removing the ~/.groovy/grapes cache, but that didn't fix the problem. Removing the ~/.m2/repository is what actually did it for me.




回答2:


This works fine from the groovy console and from the command line.

The http-builder project is hosted on Maven Central.

Grab will actually use JCenter, but JCenter mirrors Maven Central so this resolution works.

Not sure why you would have trouble resolving transitive dependencies... it may be that you are using a proxy, for example... could also be your settings for Maven or Ivy... Check the Groovy Grapes documentation to see if you might inadvertently have something configured that causes this problem.

Also, try from groovyConsole or the command-line to rule out some conflicts within IntelliJ.

From IntelliJ, point to the Grab annotation and hit Alt+Enter. Then select grab artifacts and Enter.

It should work (works for me) and you should be able to run the script without problems.

If it complains about Ivy not being in the classpath, just add Ivy to the module dependencies and it will work.



来源:https://stackoverflow.com/questions/37559458/groovy-install-httpbuilder-now-that-codehaus-shutdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!