How to import groovyx.net.http
Asked Answered
I

3

17

I don't understand maven or grape, and I'm an idiot so give me the step by step if your answer is "go grap X-dependency manager and then rtfm and you're set." Where do i find and dump files to make this line work:

import groovyx.net.http.HTTPBuilder

It says Groovy: unable to resolve class groovyx.net.http.HTTPBuilder

Also I am unable to import groovyx.net.http.ContentType.URLENC It says unable to resolve class groovyx.net.http.ContentType.URLENC

Update:

apparently you can uncomment the line mavenRepo "http://repository.codehaus.org" in BuildConfig.groovy

Impostume answered 1/7, 2011 at 20:1 Comment(0)
R
17

Since you're talking about BuildConfig.groovy I assume the question is targeted at using HttpBuilder in a grails application. If so, you could either use

compile('org.codehaus.groovy.modules.http-builder:http-builder:0.5.0') {
        excludes "commons-logging", "xml-apis", "groovy"
}

in the dependencies-section of BuildConfig.groovy, or, even more easier, just install the rest plugin:

grails install-plugin rest
Ragin answered 1/7, 2011 at 21:49 Comment(2)
I'm accepting this, but I think I had already installed rest prior to asking my question. Not sure. Also I don't understand your answer. I fixed my problem by uncommenting the line I said at the end of my question. Thanks for help, though.Impostume
Note that "install-plugin" doesn't seem to work anymore. God I miss node and npm so much since starting a Grails project...Regelate
E
1

try importing the .jar for HTTPBuilder-http://repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/0.5.2/

Ebeneser answered 14/8, 2014 at 7:16 Comment(1)
link is outdatedPentalpha
Y
0

Thom Nichols actually provided a helpful answer at http://groovy.329449.n5.nabble.com/problem-running-http-builder-code-td3995735.html to a similar question.

Basically, you can get into one of the snapshot directories at http://snapshots.repository.codehaus.org/org/codehaus/groovy/modules/http-builder/http-builder/ and download one of the packages ending with 'all'. Inside there, you'll find a dependencies directory that contains all the dependencies you need, which you can place in your lib directory. The root of the all zip (or tar) file should contain the main http-builder-#.#-SNAPSHOT.jar, which you should also place in lib.

I was doing this just from the Groovy Console. For Grails, I imagine Stefan's answer of just installing the Grails rest plugin is the best bet.

Yan answered 22/3, 2013 at 22:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.