public class DependencyCustomizer
extends java.lang.Object
@Grab annotation being added to the primary class is the module that's being customized.
This class provides a fluent API for conditionally adding dependencies. For example:
dependencies.ifMissing("com.corp.SomeClass").add(module).
| Modifier | Constructor and Description |
|---|---|
protected |
DependencyCustomizer(DependencyCustomizer parent)
Create a new nested
DependencyCustomizer. |
|
DependencyCustomizer(groovy.lang.GroovyClassLoader loader,
org.codehaus.groovy.ast.ModuleNode moduleNode,
DependencyResolutionContext dependencyResolutionContext)
Create a new
DependencyCustomizer instance. |
| Modifier and Type | Method and Description |
|---|---|
DependencyCustomizer |
add(java.lang.String... modules)
Add dependencies and all of their dependencies.
|
DependencyCustomizer |
add(java.lang.String module,
boolean transitive)
Add a single dependency and, optionally, all of its dependencies.
|
DependencyCustomizer |
add(java.lang.String module,
java.lang.String classifier,
java.lang.String type,
boolean transitive)
Add a single dependency with the specified classifier and type and, optionally, all
of its dependencies.
|
protected boolean |
canAdd()
Strategy called to test if dependencies can be added.
|
DependencyResolutionContext |
getDependencyResolutionContext()
Returns the
DependencyResolutionContext. |
java.lang.String |
getVersion(java.lang.String artifactId) |
java.lang.String |
getVersion(java.lang.String artifactId,
java.lang.String defaultVersion) |
DependencyCustomizer |
ifAllMissingClasses(java.lang.String... classNames)
Create a nested
DependencyCustomizer that only applies if all of the
specified class names are not on the class path. |
DependencyCustomizer |
ifAllResourcesPresent(java.lang.String... paths)
Create a nested
DependencyCustomizer that only applies if the specified
paths are on the class path. |
DependencyCustomizer |
ifAnyMissingClasses(java.lang.String... classNames)
Create a nested
DependencyCustomizer that only applies if any of the
specified class names are not on the class path. |
DependencyCustomizer |
ifAnyResourcesPresent(java.lang.String... paths)
Create a nested
DependencyCustomizer that only applies at least one of the
specified paths is on the class path. |
public DependencyCustomizer(groovy.lang.GroovyClassLoader loader,
org.codehaus.groovy.ast.ModuleNode moduleNode,
DependencyResolutionContext dependencyResolutionContext)
DependencyCustomizer instance.loader - the current classloadermoduleNode - the current moduledependencyResolutionContext - the context for dependency resolutionprotected DependencyCustomizer(DependencyCustomizer parent)
DependencyCustomizer.parent - the parent customizerpublic java.lang.String getVersion(java.lang.String artifactId)
public java.lang.String getVersion(java.lang.String artifactId,
java.lang.String defaultVersion)
public DependencyCustomizer ifAnyMissingClasses(java.lang.String... classNames)
DependencyCustomizer that only applies if any of the
specified class names are not on the class path.classNames - the class names to testDependencyCustomizerpublic DependencyCustomizer ifAllMissingClasses(java.lang.String... classNames)
DependencyCustomizer that only applies if all of the
specified class names are not on the class path.classNames - the class names to testDependencyCustomizerpublic DependencyCustomizer ifAllResourcesPresent(java.lang.String... paths)
DependencyCustomizer that only applies if the specified
paths are on the class path.paths - the paths to testDependencyCustomizerpublic DependencyCustomizer ifAnyResourcesPresent(java.lang.String... paths)
DependencyCustomizer that only applies at least one of the
specified paths is on the class path.paths - the paths to testDependencyCustomizerpublic DependencyCustomizer add(java.lang.String... modules)
ArtifactCoordinatesResolver.modules - the module IDsDependencyCustomizer for continued usepublic DependencyCustomizer add(java.lang.String module, boolean transitive)
ArtifactCoordinatesResolver.module - the module IDtransitive - true if the transitive dependencies should also be added,
otherwise falseDependencyCustomizer for continued usepublic DependencyCustomizer add(java.lang.String module, java.lang.String classifier, java.lang.String type, boolean transitive)
ArtifactCoordinatesResolver.module - the module IDclassifier - the classifier, may be nulltype - the type, may be nulltransitive - true if the transitive dependencies should also be added,
otherwise falseDependencyCustomizer for continued useprotected boolean canAdd()
true by default.true if dependencies can be added, otherwise falsepublic DependencyResolutionContext getDependencyResolutionContext()
DependencyResolutionContext.