groovy.lang

## Annotation Type Grab

    @Retention(value=SOURCE)
    @Target(value={CONSTRUCTOR,FIELD,LOCAL_VARIABLE,METHOD,PARAMETER,TYPE})
    public @interface Grab

Used to grab the referenced artifact and its dependencies and make it available on the Classpath.

Some examples:

     @Grab(group='commons-lang', module='commons-lang', version='2.4')
     import org.apache.commons.lang.WordUtils
     println "Hello ${WordUtils.capitalize('world')}"

Or using the compact Gradle-inspired syntax:

     @Grab('commons-lang:commons-lang:2.4')
     import org.apache.commons.lang.WordUtils
     println "Hello ${WordUtils.capitalize('world')}"

or the same thing again using the Ivy-inspired syntax variant:

     @Grab('commons-lang#commons-lang;2.4')
     import org.apache.commons.lang.WordUtils
     println "Hello ${WordUtils.capitalize('world')}"

### Required Element Summary

Required Elements
`String` `module` The module or artifact, e.g.: "ant-junit"
`String` `version` The revision or version, e.g.: "1.7.1"

### Optional Element Summary

Optional Elements
`String` `classifier` The classifier if in use, e.g.: "jdk14"
`String` `conf` The configuration if in use (normally only used by internal ivy repositories).
`String` `ext` The extension of the artifact (normally safe to leave at default value of "jar")
`String` `group` The organisation or group, e.g.: "org.apache.ant"
`boolean` `initClass` By default, when a `@Grab` annotation is used, the `grab()` call is added to the static initializers of the class the annotatable node appears in.
`boolean` `transitive` Set to false if you don't want transitive dependencies also to be downloaded.
`String` `value` Allows a more compact convenience format in one of two formats.

### Element Detail

#### module

    public abstract String module

The module or artifact, e.g.: "ant-junit"

#### version

    public abstract String version

The revision or version, e.g.: "1.7.1"

#### group

    public abstract String group

The organisation or group, e.g.: "org.apache.ant"

Default:
  ""

#### classifier

    public abstract String classifier

The classifier if in use, e.g.: "jdk14"

Default:
  ""

#### transitive

    public abstract boolean transitive

Set to false if you don't want transitive dependencies also to be downloaded. You may then need additional `@Grab` statements for any required dependencies.

Default:
  true

#### conf

    public abstract String conf

The configuration if in use (normally only used by internal ivy repositories). One or more coma separated values with or without square brackets, e.g. for hibernate you might have "default,proxool,oscache" or "[default,dbcp,swarmcache]". This last hibernate example assumes you have set up such configurations in your local Ivy repo and changed your grape config to point to that repo.

Default:
  ""

#### ext

    public abstract String ext

The extension of the artifact (normally safe to leave at default value of "jar")

Default:
  ""

#### value

    public abstract String value

Allows a more compact convenience format in one of two formats.

You can choose either format but not mix-n-match:
`group:module:version:classifier@ext` (where only group and module are required)
`group#module;version[confs]` (where only group and module are required and confs, if used, is one or more comma separated configuration names)

Default:
  ""

#### initClass

    public abstract boolean initClass

By default, when a `@Grab` annotation is used, the `grab()` call is added to the static initializers of the class the annotatable node appears in. If you wish to disable this, add `initClass=false` to the annotation.

Default:
  true