public class DependencyCustomizer extends 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(String... modules)
Add dependencies and all of their dependencies.
|
DependencyCustomizer |
add(String module,
boolean transitive)
Add a single dependency and, optionally, all of its dependencies.
|
DependencyCustomizer |
add(String module,
String classifier,
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. |
String |
getVersion(String artifactId) |
String |
getVersion(String artifactId,
String defaultVersion) |
DependencyCustomizer |
ifAllMissingClasses(String... classNames)
Create a nested
DependencyCustomizer that only applies if all of the
specified class names are not on the class path. |
DependencyCustomizer |
ifAllResourcesPresent(String... paths)
Create a nested
DependencyCustomizer that only applies if the specified
paths are on the class path. |
DependencyCustomizer |
ifAnyMissingClasses(String... classNames)
Create a nested
DependencyCustomizer that only applies if any of the
specified class names are not on the class path. |
DependencyCustomizer |
ifAnyResourcesPresent(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 DependencyCustomizer ifAnyMissingClasses(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(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(String... paths)
DependencyCustomizer that only applies if the specified
paths are on the class path.paths - the paths to testDependencyCustomizerpublic DependencyCustomizer ifAnyResourcesPresent(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(String... modules)
ArtifactCoordinatesResolver.modules - The module IDsDependencyCustomizer for continued usepublic DependencyCustomizer add(String module, boolean transitive)
ArtifactCoordinatesResolver.module - The module IDtransitive - true if the transitive dependencies should also be added,
otherwise false.DependencyCustomizer for continued usepublic DependencyCustomizer add(String module, String classifier, 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 false.DependencyCustomizer for continued useprotected boolean canAdd()
true by default.true if dependencies can be added, otherwise falsepublic DependencyResolutionContext getDependencyResolutionContext()
DependencyResolutionContext.Copyright © 2018 Pivotal Software, Inc.. All rights reserved.