|
Groovy 2.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
java.lang.Object groovy.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 |
module
The module or artifact, e.g.: "ant-junit" |
java.lang.String |
version
The revision or version, e.g.: "1.7.1" |
Optional Element Summary | |
---|---|
boolean |
changing
Defaults to |
java.lang.String |
classifier
The classifier if in use, e.g.: "jdk14" @default "" |
java.lang.String |
conf
The configuration if in use (normally only used by internal ivy repositories). |
java.lang.String |
ext
The extension of the artifact (normally safe to leave at default value of "jar" but other values like "zip" are sometimes useful). |
boolean |
force
Defaults to |
java.lang.String |
group
The organisation or group, e.g.: "org.apache.ant" @default "" |
boolean |
initClass
By default, when a |
boolean |
transitive
Defaults to |
java.lang.String |
type
The 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 |
value
Allows a more compact convenience form in one of two formats with optional appended attributes. |
Method Summary |
---|
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Element Detail |
---|
public boolean changing
false
but set to true
if 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
public String classifier
public String conf
@GrabConfig
annotation
to point to that repo.
@default ""
public String ext
public boolean force
false
but set to true
to 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
public String group
public boolean initClass
@Grab
annotation is used, a Grape.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
public String module
public boolean transitive
true
but 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
public String type
public String value
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 ""
public String version
Copyright © 2003-2013 The Codehaus. All rights reserved.