| 
 | Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||
java.lang.Objectgroovy.lang.Grab
@Retention(RetentionPolicy.SOURCE)
@Target({
        ElementType.CONSTRUCTOR,
        ElementType.FIELD,
        ElementType.LOCAL_VARIABLE,
        ElementType.METHOD,
        ElementType.PARAMETER,
        ElementType.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')}"
 
 Further information such as where artifacts are downloaded to, how to add additional resolvers,
 how to customise artifact resolution etc., can be found on the Grape documentation page:
 http://groovy.codehaus.org/Grape.
 
| Required Element Summary | |
|---|---|
| java.lang.String | moduleThe module or artifact, e.g.: "ant-junit" | 
| java.lang.String | versionThe revision or version, e.g.: "1.7.1" | 
| Optional Element Summary | |
|---|---|
| boolean | changingDefaults to false but set to true if the dependency artifacts may change without a corresponding revision change. | 
| java.lang.String | classifierThe classifier if in use, e.g.: "jdk14" @default "" | 
| java.lang.String | confThe configuration if in use (normally only used by internal ivy repositories). | 
| java.lang.String | extThe extension of the artifact (normally safe to leave at default value of "jar" but other values like "zip" are sometimes useful). | 
| boolean | forceDefaults to false but set to true to indicate to the underlying Ivy conflict manager that this dependency should be forced to the given revision. | 
| java.lang.String | groupThe organisation or group, e.g.: "org.apache.ant" @default "" | 
| boolean | initClassBy 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 | transitiveDefaults to true but set to false if you don't want transitive dependencies also to be downloaded. | 
| java.lang.String | typeThe type of the artifact (normally safe to leave at default value of "jar" but other values like "sources" and "javadoc" are sometimes useful). | 
| java.lang.String | valueAllows a more compact convenience form in one of two formats with optional appended attributes. | 
| Method Summary | 
|---|
| Methods inherited from class java.lang.Object | |
|---|---|
| java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() | 
| Element Detail | 
|---|
public boolean changing
public java.lang.String classifier
public java.lang.String conf
public java.lang.String ext
public boolean force
public java.lang.String group
public boolean initClass
public java.lang.String module
public boolean transitive
public java.lang.String type
public java.lang.String value
public java.lang.String version
Groovy Documentation