Class DefaultDependencyResolverResult
java.lang.Object
org.apache.maven.impl.DefaultDependencyResolverResult
- All Implemented Interfaces:
DependencyResolverResult,Result<DependencyResolverRequest>
The result of collecting dependencies with a dependency resolver.
New instances are initially empty. Callers must populate with calls
to the following methods, in that order:
addOutputDirectory(Path, Path)(optional)addDependency(Node, Dependency, Predicate, Path)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultDependencyResolverResult(DependencyResolverRequest request, org.apache.maven.impl.PathModularizationCache cache, List<Exception> exceptions, Node root, int count) Creates an initially empty result. -
Method Summary
Modifier and TypeMethodDescriptionReturns all dependencies associated with their paths.Returns the file paths of all dependencies and their assignments to different paths.Gets the exceptions that occurred while building the dependency graph.getModuleDescriptor(Path dependency) Returns the Java module descriptor of the dependency at the given path.getModuleName(Path dependency) Returns the Java module name of the dependency at the given path.getNodes()The ordered list of the flattened dependency nodes.getPaths()Returns the file paths of all dependencies, regardless of which tool option those paths should be placed on.Returns the request that produced this result.getRoot()Gets the root node of the dependency graph.If the module path contains at least one filename-based auto-module, prepares a warning message.
-
Constructor Details
-
DefaultDependencyResolverResult
public DefaultDependencyResolverResult(DependencyResolverRequest request, org.apache.maven.impl.PathModularizationCache cache, List<Exception> exceptions, Node root, int count) Creates an initially empty result. Callers should add path elements by calls toaddDependency(Node, Dependency, Predicate, Path).- Parameters:
request- the corresponding requestcache- cache of module information about each dependencyexceptions- the exceptions that occurred while building the dependency graphroot- the root node of the dependency graphcount- estimated number of dependencies
-
-
Method Details
-
getRequest
Description copied from interface:ResultReturns the request that produced this result.- Specified by:
getRequestin interfaceResult<DependencyResolverRequest>- Returns:
- the originating request instance, never
null
-
getExceptions
Description copied from interface:DependencyResolverResultGets the exceptions that occurred while building the dependency graph.- Specified by:
getExceptionsin interfaceDependencyResolverResult- Returns:
- the exceptions that occurred, never
null
-
getRoot
Description copied from interface:DependencyResolverResultGets the root node of the dependency graph.- Specified by:
getRootin interfaceDependencyResolverResult- Returns:
- the root node of the dependency graph or
nullif none
-
getNodes
Description copied from interface:DependencyResolverResultThe ordered list of the flattened dependency nodes.- Specified by:
getNodesin interfaceDependencyResolverResult- Returns:
- the ordered list of the flattened dependency nodes
-
getPaths
Description copied from interface:DependencyResolverResultReturns the file paths of all dependencies, regardless of which tool option those paths should be placed on. The returned list may contain a mix of Java class path, Java module path, and other types of path elements. This collection has the same content asgetDependencies.values()except that it does not contain null elements.- Specified by:
getPathsin interfaceDependencyResolverResult- Returns:
- the paths of all dependencies
-
getDispatchedPaths
Description copied from interface:DependencyResolverResultReturns the file paths of all dependencies and their assignments to different paths. ThePathTypekeys identify, for example,--class-pathor--module-pathoptions. In the case of Java tools, the map may also contain--patch-moduleoptions, which are handled in a special way.Design note
All types of path are determined together because they are sometime mutually exclusive. For example, an artifact of type "jar" can be placed either on the class-path or on the module-path. The project needs to make a choice (possibly using heuristic rules), then add the dependency in only one of the paths identified byPathType.- Specified by:
getDispatchedPathsin interfaceDependencyResolverResult- Returns:
- file paths to place on the different tool options
-
getDependencies
Description copied from interface:DependencyResolverResultReturns all dependencies associated with their paths. Some dependencies may be associated with a null value if there is no path available.- Specified by:
getDependenciesin interfaceDependencyResolverResult- Returns:
- all dependencies associated with their paths
-
getModuleDescriptor
Description copied from interface:DependencyResolverResultReturns the Java module descriptor of the dependency at the given path. The given dependency should be one of the paths returned byDependencyResolverResult.getDependencies(). The module descriptor is extracted from themodule-info.classfile if present.DependencyResolverResult.getModuleName(Path)is preferred when only the module name is desired, because a name may be present even if the descriptor is absent. This method is for cases when more information is desired, such as the set of exported packages.- Specified by:
getModuleDescriptorin interfaceDependencyResolverResult- Parameters:
dependency- path to the dependency for which to get the module name- Returns:
- module name of the dependency at the given path, or empty if the dependency is not modular
- Throws:
IOException- if the module information of the specified dependency cannot be read
-
getModuleName
Description copied from interface:DependencyResolverResultReturns the Java module name of the dependency at the given path. The given dependency should be one of the paths returned byDependencyResolverResult.getDependencies(). The module name is extracted from themodule-info.classfile if present, otherwise from the"Automatic-Module-Name"attribute of theMETA-INF/MANIFEST.MFfile if present.A typical usage is to invoke this method for all dependencies having a
TESTorTEST_ONLYscope. An--add-readsoption may need to be generated for compiling and running the test classes that use such dependencies.- Specified by:
getModuleNamein interfaceDependencyResolverResult- Parameters:
dependency- path to the dependency for which to get the module name- Returns:
- module name of the dependency at the given path, or empty if the dependency is not modular
- Throws:
IOException- if the module information of the specified dependency cannot be read
-
warningForFilenameBasedAutomodules
Description copied from interface:DependencyResolverResultIf the module path contains at least one filename-based auto-module, prepares a warning message. The module path is the collection of dependencies associated withJavaPathType.MODULES. It is caller's responsibility to send the message to a logger.- Specified by:
warningForFilenameBasedAutomodulesin interfaceDependencyResolverResult- Returns:
- warning message if at least one filename-based auto-module was found
-