Why can't my script fetch a Grapes dependency?

386 views Asked by At

I have a script with a Grapes dependency, shown below:

@Grapes(@Grab(group="commons-io", module="commons-io", version="2.4"))
import org.apache.commons.io.output.TeeOutputStream
...

But when I run it, I'm getting an error that the dependency can't be found.

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes -- [unresolved dependency: commons-io#commons-io;2.4: not found]

java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: commons-io#commons-io;2.4: not found]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
...

I'm using Groovy 2.0.5 with Java 1.6.0_33.

I checked Maven central and the dependency does exist. Why can't Grapes find it?

1

There are 1 answers

0
ou_ryperd On

These two ways work for me in Eclipse, but not in Netbeans. Whichever way you use, your group should be org.apache.commons

groovy.grape.Grape.grab(group:'org.apache.commons', module:'commons-lang3', version:'3.3.2')

or:

@Grab(group='org.apache.commons', module='commons-lang3', version='3.3.2')