Grape support


I am starting to develop some scripts in Groovy which requires some Maven dependencies. I have a new project, with a Java module, with Groovy support enabled (1.8.6, installed from repos for Ubuntu as described here), and then created this script:

package okelet.ldap

@Grab(group='com.unboundid', module='unboundid-ldapsdk', version='2.3.0')
import com.unboundid.ldap.sdk.LDAPConnection;

println("Creating connection...")
LDAPConnection ldapConnection = new LDAPConnection();

As I have annotated the "import" with a "Grab", I suppose to Groovy automatically download that dependency from Maven; if I run the script from the console, the script works fine, but IDEA doesn't recognise the annotation, as the editor always says "Cannot resolve symbol 'unboundid'" in the import statement, and "Cannot resolve symbol 'LDAPConnection'", and so the code completion does not work. What should be the correct behaviour of IDEA? Should it download the dependencies and import them to the project?

Thanks in advance.

1 comment
Comment actions Permalink

Currently you can place your caret on the @Grab annotation, press Alt+Enter and invoke Grab Dependencies. For automatic Grape processing please vote/watch


Please sign in to leave a comment.