public class DependencyCustomizer extends java.lang.Object
Customizer that allows dependencies to be added during compilation. Adding a dependency results in a groovy.lang.Grab annotation being added to the primary org.codehaus.groovy.ast.ClassNode is the org.codehaus.groovy.ast.ModuleNode that's being customized.
This class provides a fluent API for conditionally adding dependencies. For example:
dependencies.ifMissing("com.corp.SomeClass").add(module)
.
Constructor and description |
---|
DependencyCustomizer(groovy.lang.GroovyClassLoader loader, org.codehaus.groovy.ast.ModuleNode moduleNode, DependencyResolutionContext dependencyResolutionContext) Create a new DependencyCustomizer instance. |
protected DependencyCustomizer(DependencyCustomizer parent) Create a new nested DependencyCustomizer. |
Type Params | Return Type | Name and description |
---|---|---|
|
public DependencyCustomizer |
add(java.lang.String modules) Add dependencies and all of their dependencies. |
|
public DependencyCustomizer |
add(java.lang.String module, boolean transitive) Add a single dependency and, optionally, all of its dependencies. |
|
public 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() |
|
protected boolean |
canAdd() |
|
protected boolean |
canAdd() |
|
protected boolean |
canAdd() |
|
protected boolean |
canAdd() Strategy called to test if dependencies can be added. |
|
public DependencyResolutionContext |
getDependencyResolutionContext() Returns the DependencyResolutionContext. |
|
public java.lang.String |
getVersion(java.lang.String artifactId) |
|
public java.lang.String |
getVersion(java.lang.String artifactId, java.lang.String defaultVersion) |
|
public DependencyCustomizer |
ifAllMissingClasses(java.lang.String classNames) Create a nested DependencyCustomizer that only applies if all the specified class names are not on the class path. |
|
public DependencyCustomizer |
ifAllResourcesPresent(java.lang.String paths) Create a nested DependencyCustomizer that only applies if the specified paths are on the class path. |
|
public 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. |
|
public 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. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), 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() |
Create a new DependencyCustomizer instance.
loader
- the current classloadermoduleNode
- the current moduledependencyResolutionContext
- the context for dependency resolutionCreate a new nested DependencyCustomizer.
parent
- the parent customizerAdd dependencies and all of their dependencies. The group ID and version of the dependencies are resolved from the modules using the customizer's ArtifactCoordinatesResolver.
modules
- the module IDsAdd a single dependency and, optionally, all of its dependencies. The group ID and version of the dependency are resolved from the module using the customizer's ArtifactCoordinatesResolver.
module
- the module IDtransitive
- true
if the transitive dependencies should also be added,
otherwise false
Add a single dependency with the specified classifier and type and, optionally, all of its dependencies. The group ID and version of the dependency are resolved from the module by using the customizer's ArtifactCoordinatesResolver.
module
- the module IDclassifier
- the classifier, may be null
type
- the type, may be null
transitive
- true
if the transitive dependencies should also be added,
otherwise false
Strategy called to test if dependencies can be added. Subclasses override as
required. Returns true
by default.
true
if dependencies can be added, otherwise false
Returns the DependencyResolutionContext.
Create a nested DependencyCustomizer that only applies if all the specified class names are not on the class path.
classNames
- the class names to testCreate a nested DependencyCustomizer that only applies if the specified paths are on the class path.
paths
- the paths to testCreate a nested DependencyCustomizer that only applies if any of the specified class names are not on the class path.
classNames
- the class names to testCreate a nested DependencyCustomizer that only applies at least one of the specified paths is on the class path.
paths
- the paths to test