groovy.lang
[Java] Annotation Type Grapes
java.lang.Object
groovy.lang.Grapes
public @interface Grapes
Sometimes we will need more than one grab per class, but we can only add
one annotation type per annotatable node. This class allows for multiple
grabs to be added.
For example:
@Grapes([@Grab(module='m1'), @Grab(module='m2')])
class AnnotatedClass { ... }
You can override an implicit transitive dependency by providing an explicit one.
E.g. htmlunit 2.6 normally uses xerces 2.9.1 but you can get 2.9.0 as follows:
@Grapes([
@Grab('net.sourceforge.htmlunit:htmlunit:2.6'),
@Grab('xerces#xercesImpl;2.9.0')
])
Obviously, only do this if you understand the consequences.
You can also remove transitive dependencies altogether (provided you
know you don't need them) using @GrabExclude.
For example, here is how we would not grab the logkit and
avalon-framework transitive dependencies for Apache POI:
@Grapes([
@Grab("org.apache.poi#poi;3.5-beta6"),
@GrabExclude("logkit:logkit"),
@GrabExclude("avalon-framework#avalon-framework")
])
import org.apache.poi.hssf.util.CellReference
assert new CellReference(0, 0, false, false).formatAsString() == 'A1'
assert new CellReference(1, 3).formatAsString() == '$D$2'
It is also sometimes also useful to use @GrabConfig to further adjust how dependencies
are grabbed. See @GrabConfig for further information.
Required Element Summary |
null |
value
|
Optional Element Summary |
boolean |
initClass
This will be pushed into the child grab annotations if the value is not
set in the child annotation already.
|
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() |
initClass
public boolean initClass
- This will be pushed into the child grab annotations if the value is not
set in the child annotation already.
This results in an effective change in the default value, which each @Grab
can still override
@default true
value
public Grab[] value
-
Groovy Documentation