Class CollectRequest
- java.lang.Object
-
- org.apache.maven.shared.transfer.collection.CollectRequest
-
public final class CollectRequest extends java.lang.Object
A request to collect the transitive dependencies and to build a dependency graph from them. There are three ways to create a dependency graph. First, only the root dependency can be given. Second, a root dependency and direct dependencies can be specified in which case the specified direct dependencies are merged with the direct dependencies retrieved from the artifact descriptor of the root dependency. And last, only direct dependencies can be specified in which case the root node of the resulting graph has no associated dependency.- See Also:
DependencyCollector.collectDependencies(org.apache.maven.project.ProjectBuildingRequest, org.apache.maven.model.Dependency)
,DependencyCollector.collectDependencies(org.apache.maven.project.ProjectBuildingRequest, org.apache.maven.shared.transfer.dependencies.DependableCoordinate)
,DependencyCollector.collectDependencies(org.apache.maven.project.ProjectBuildingRequest, org.apache.maven.model.Model)
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<org.apache.maven.model.Dependency>
dependencies
private java.util.List<org.apache.maven.model.Dependency>
managedDependencies
private java.util.List<org.apache.maven.artifact.repository.ArtifactRepository>
repositories
private org.apache.maven.model.Dependency
root
private org.apache.maven.artifact.Artifact
rootArtifact
-
Constructor Summary
Constructors Constructor Description CollectRequest()
Creates an uninitialized request.CollectRequest(java.util.List<org.apache.maven.model.Dependency> dependencies, java.util.List<org.apache.maven.model.Dependency> managedDependencies, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Creates a new request with the specified properties.CollectRequest(org.apache.maven.model.Dependency root, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Creates a request with the specified properties.CollectRequest(org.apache.maven.model.Dependency root, java.util.List<org.apache.maven.model.Dependency> dependencies, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Creates a new request with the specified properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CollectRequest
addDependency(org.apache.maven.model.Dependency dependency)
Adds the specified direct dependency.CollectRequest
addManagedDependency(org.apache.maven.model.Dependency managedDependency)
Adds the specified managed dependency.CollectRequest
addRepository(org.apache.maven.artifact.repository.ArtifactRepository repository)
Adds the specified repository for collection.java.util.List<org.apache.maven.model.Dependency>
getDependencies()
Gets the direct dependencies.java.util.List<org.apache.maven.model.Dependency>
getManagedDependencies()
Gets the dependency management to apply to transitive dependencies.java.util.List<org.apache.maven.artifact.repository.ArtifactRepository>
getRepositories()
Gets the repositories to use for the collection.org.apache.maven.model.Dependency
getRoot()
Gets the root dependency of the graph.org.apache.maven.artifact.Artifact
getRootArtifact()
Gets the root artifact for the dependency graph.CollectRequest
setDependencies(java.util.List<org.apache.maven.model.Dependency> dependencies)
Sets the direct dependencies.CollectRequest
setManagedDependencies(java.util.List<org.apache.maven.model.Dependency> managedDependencies)
Sets the dependency management to apply to transitive dependencies.CollectRequest
setRepositories(java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Sets the repositories to use for the collection.CollectRequest
setRoot(org.apache.maven.model.Dependency root)
Sets the root dependency of the graph.CollectRequest
setRootArtifact(org.apache.maven.artifact.Artifact rootArtifact)
Sets the root artifact for the dependency graph.java.lang.String
toString()
-
-
-
Field Detail
-
rootArtifact
private org.apache.maven.artifact.Artifact rootArtifact
-
root
private org.apache.maven.model.Dependency root
-
dependencies
private java.util.List<org.apache.maven.model.Dependency> dependencies
-
managedDependencies
private java.util.List<org.apache.maven.model.Dependency> managedDependencies
-
repositories
private java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories
-
-
Constructor Detail
-
CollectRequest
public CollectRequest()
Creates an uninitialized request.
-
CollectRequest
public CollectRequest(org.apache.maven.model.Dependency root, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Creates a request with the specified properties.- Parameters:
root
- The root dependency whose transitive dependencies should be collected, may benull
.repositories
- The repositories to use for the collection, may benull
.
-
CollectRequest
public CollectRequest(org.apache.maven.model.Dependency root, java.util.List<org.apache.maven.model.Dependency> dependencies, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Creates a new request with the specified properties.- Parameters:
root
- The root dependency whose transitive dependencies should be collected, may benull
.dependencies
- The direct dependencies to merge with the direct dependencies from the root dependency's artifact descriptor.repositories
- The repositories to use for the collection, may benull
.
-
CollectRequest
public CollectRequest(java.util.List<org.apache.maven.model.Dependency> dependencies, java.util.List<org.apache.maven.model.Dependency> managedDependencies, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Creates a new request with the specified properties.- Parameters:
dependencies
- The direct dependencies of some imaginary root, may benull
.managedDependencies
- The dependency management information to apply to the transitive dependencies, may benull
.repositories
- The repositories to use for the collection, may benull
.
-
-
Method Detail
-
getRootArtifact
public org.apache.maven.artifact.Artifact getRootArtifact()
Gets the root artifact for the dependency graph.- Returns:
- The root artifact for the dependency graph or
null
if none.
-
setRootArtifact
public CollectRequest setRootArtifact(org.apache.maven.artifact.Artifact rootArtifact)
Sets the root artifact for the dependency graph. This must not be confused withsetRoot(Dependency)
: The root dependency, like any other specified dependency, will be subject to dependency collection/resolution, i.e. should have an artifact descriptor and a corresponding artifact file. The root artifact on the other hand is only used as a label for the root node of the graph in case no root dependency was specified. As such, the configured root artifact is ignored ifgetRoot()
does not returnnull
.- Parameters:
rootArtifact
- The root artifact for the dependency graph, may benull
.- Returns:
- This request for chaining, never
null
.
-
getRoot
public org.apache.maven.model.Dependency getRoot()
Gets the root dependency of the graph.- Returns:
- The root dependency of the graph or
null
if none.
-
setRoot
public CollectRequest setRoot(org.apache.maven.model.Dependency root)
Sets the root dependency of the graph.- Parameters:
root
- The root dependency of the graph, may benull
.- Returns:
- This request for chaining, never
null
.
-
getDependencies
public java.util.List<org.apache.maven.model.Dependency> getDependencies()
Gets the direct dependencies.- Returns:
- The direct dependencies, never
null
.
-
setDependencies
public CollectRequest setDependencies(java.util.List<org.apache.maven.model.Dependency> dependencies)
Sets the direct dependencies. If both a root dependency and direct dependencies are given in the request, the direct dependencies from the request will be merged with the direct dependencies from the root dependency's artifact descriptor, giving higher priority to the dependencies from the request.- Parameters:
dependencies
- The direct dependencies, may benull
.- Returns:
- This request for chaining, never
null
.
-
addDependency
public CollectRequest addDependency(org.apache.maven.model.Dependency dependency)
Adds the specified direct dependency.- Parameters:
dependency
- The dependency to add, may benull
.- Returns:
- This request for chaining, never
null
.
-
getManagedDependencies
public java.util.List<org.apache.maven.model.Dependency> getManagedDependencies()
Gets the dependency management to apply to transitive dependencies.- Returns:
- The dependency management to apply to transitive dependencies, never
null
.
-
setManagedDependencies
public CollectRequest setManagedDependencies(java.util.List<org.apache.maven.model.Dependency> managedDependencies)
Sets the dependency management to apply to transitive dependencies. To clarify, this management does not apply to the direct dependencies of the root node.- Parameters:
managedDependencies
- The dependency management, may benull
.- Returns:
- This request for chaining, never
null
.
-
addManagedDependency
public CollectRequest addManagedDependency(org.apache.maven.model.Dependency managedDependency)
Adds the specified managed dependency.- Parameters:
managedDependency
- The managed dependency to add, may benull
.- Returns:
- This request for chaining, never
null
.
-
getRepositories
public java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> getRepositories()
Gets the repositories to use for the collection.- Returns:
- The repositories to use for the collection, never
null
.
-
setRepositories
public CollectRequest setRepositories(java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Sets the repositories to use for the collection.- Parameters:
repositories
- The repositories to use for the collection, may benull
.- Returns:
- This request for chaining, never
null
.
-
addRepository
public CollectRequest addRepository(org.apache.maven.artifact.repository.ArtifactRepository repository)
Adds the specified repository for collection.- Parameters:
repository
- The repository to collect dependency information from, may benull
.- Returns:
- This request for chaining, never
null
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-