Package groovy.lang
Annotation Type Grab
@Retention(SOURCE)
@Target({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')}"
 
 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-lang.org/grape.html.- 
Optional Element SummaryOptional Elements Modifier and Type Optional Element Description booleanchangingDefaults tofalsebut set totrueif the dependency artifacts may change without a corresponding revision change.java.lang.StringclassifierThe classifier if in use, e.g.: "jdk14"java.lang.StringconfThe configuration if in use (normally only used by internal ivy repositories).java.lang.StringextThe extension of the artifact (normally safe to leave at default value of "jar" but other values like "zip" are sometimes useful).booleanforceDefaults tofalsebut set totrueto indicate to the underlying Ivy conflict manager that this dependency should be forced to the given revision.java.lang.StringgroupThe organisation or group, e.g.: "org.apache.ant".booleaninitClassBy default, when a@Grabannotation is used, aGrape.grab()call is added to the static initializers of the class the annotatable node appears in.java.lang.StringmoduleThe module or artifact, e.g.: "ant-junit".booleantransitiveDefaults totruebut set tofalseif you don't want transitive dependencies also to be downloaded.java.lang.StringtypeThe 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.StringvalueAllows a more compact convenience form in one of two formats with optional appended attributes.java.lang.StringversionThe revision or version, e.g.: "1.7.1".
- 
Element Details- 
groupjava.lang.String groupThe organisation or group, e.g.: "org.apache.ant". A non-empty value is required unless value() is used.- Default:
- ""
 
- 
modulejava.lang.String moduleThe module or artifact, e.g.: "ant-junit". A non-empty value is required unless value() is used.- Default:
- ""
 
- 
versionjava.lang.String versionThe revision or version, e.g.: "1.7.1". A non-empty value is required unless value() is used.- Default:
- ""
 
- 
classifierjava.lang.String classifierThe classifier if in use, e.g.: "jdk14"- Default:
- ""
 
- 
transitiveboolean transitiveDefaults totruebut set tofalseif you don't want transitive dependencies also to be downloaded. You may then need additional@Grabstatements for any required dependencies.- Default:
- true
 
- 
forceboolean forceDefaults tofalsebut set totrueto indicate to the underlying Ivy conflict manager that this dependency should be forced to the given revision. Otherwise, depending on the conflict manager in play, a later compatible version might be used instead.- Default:
- false
 
- 
changingboolean changingDefaults tofalsebut set totrueif the dependency artifacts may change without a corresponding revision change. Not normally recommended but may be useful for certain kinds of snapshot artifacts. May reduce the amount of underlying Ivy caching. Proper behavior may be dependent on the resolver in use.- Default:
- false
 
- 
confjava.lang.String confThe configuration if in use (normally only used by internal ivy repositories). One or more comma 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 have changed your grape config (using grapeConfig.xml) or the@GrabConfigannotation to point to that repo.- Default:
- ""
 
- 
extjava.lang.String extThe extension of the artifact (normally safe to leave at default value of "jar" but other values like "zip" are sometimes useful).- Default:
- ""
 
- 
typejava.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). But see also the "classifier" attribute which is also sometimes used for "sources" and "javadoc".- Default:
- ""
 
- 
valuejava.lang.String valueAllows a more compact convenience form in one of two formats with optional appended attributes. Must not be used if group(), module() or version() are used.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)
 In addition, you can add any valid Ivy attributes at the end of your string value using semi-colon separated name = value pairs, e.g.:
 @Grab('junit:junit:*;transitive=false')
 @Grab('group=junit;module=junit;version=4.8.2;classifier=javadoc')- Default:
- ""
 
- 
initClassboolean initClassBy default, when a@Grabannotation is used, aGrape.grab()call is added to the static initializers of the class the annotatable node appears in. If you wish to disable this, addinitClass=falseto the annotation.- Default:
- true
 
 
-