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.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | changing()
Defaults to |
| public String | |
| public String | |
| public String | ext()
The extension of the artifact (normally safe to leave at default value of "jar" but other values like "zip" are sometimes useful). |
| public boolean | force()
Defaults to |
| public String | |
| public boolean | initClass()
By default, when a |
| public String | |
| public boolean | transitive()
Defaults to |
| public 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). |
| public String | value()
Allows a more compact convenience form in one of two formats with optional appended attributes. |
| public String |
| changing | back to summary |
|---|---|
| public boolean changing() Defaults to | |
| classifier | back to summary |
|---|---|
| public String classifier() The classifier if in use, e.g.: "jdk14" | |
| conf | back to summary |
|---|---|
| public String conf() The 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 | |
| ext | back to summary |
|---|---|
| public String ext() The extension of the artifact (normally safe to leave at default value of "jar" but other values like "zip" are sometimes useful). | |
| force | back to summary |
|---|---|
| public boolean force() Defaults to | |
| group | back to summary |
|---|---|
| public String group() The organisation or group, e.g.: "org.apache.ant". A non-empty value is required unless value() is used. | |
| initClass | back to summary |
|---|---|
| public boolean initClass() By default, when a | |
| module | back to summary |
|---|---|
| public String module() The module or artifact, e.g.: "ant-junit". A non-empty value is required unless value() is used. | |
| transitive | back to summary |
|---|---|
| public boolean transitive() Defaults to | |
| type | back to summary |
|---|---|
| public 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). But see also the "classifier" attribute which is also sometimes used for "sources" and "javadoc". | |
| value | back to summary |
|---|---|
| public String value() Allows 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: | |
| version | back to summary |
|---|---|
| public String version() The revision or version, e.g.: "1.7.1". A non-empty value is required unless value() is used. | |