Why is Grapes grabbing a jar I didn't ask for?

254 Views Asked by At

I want to write a simple Groovy script which uses Apache HttpClient 4.1 and since I don't have its jar, I want to grab it with Grapes. All I have so far in my script is..

@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.0')
import org.apache.http.impl.client.DefaultHttpClient;

But when I run this I get an exception..

java.lang.RuntimeException: Error grabbing Grapes -- [download failed: commons-logging#commons-logging;1.1.1!commons-logging.jar]

Why is Grapes getting commons logging when I only asked for http client? If it is because the latter needs the former, then do I need to explicitly grab all of the dependent jars of http client myself? How would I even know what they are? Is there a way to tell Grapes to do this on its own?

1

There are 1 best solutions below

3
On BEST ANSWER

This is happening because commons-logging is a transitive dependency i.e. a dependency of org.apache.httpcomponents:httpclient.

You are presumably having a problem because your local maven repo doesn't have commons-logging and doesn't know how (or isn't configured) to look for it.