groovy.lang
[Java] Annotation Type Grab
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.
Copyright © 2003-2011 The Codehaus. All rights reserved.