Package org.apache.maven.internal.impl
Class PathModularizationCache
java.lang.Object
org.apache.maven.internal.impl.PathModularizationCache
Cache of
PathModularization
instances computed for given Path
elements.
The cache is used for avoiding the need to reopen the same files many times when the
same dependency is used for different scope. For example a path used for compilation
is typically also used for tests.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<Path, PathModularization> Module information for each JAR file or output directories.Whether JAR files are modular. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) PathModularization
getModuleInfo
(Path path) Gets module information for the given JAR file or output directory.private PathType
getPathType
(Path path) ReturnsJavaPathType.MODULES
if the given JAR file or output directory is modular.Selects the type of path where to place the given dependency.warningForFilenameBasedAutomodules
(Collection<Path> modulePaths) If the module-path contains a filename-based auto-module, prepares a warning message.
-
Field Details
-
moduleInfo
Module information for each JAR file or output directories. Cached when first requested to avoid decoding the module descriptors multiple times.- See Also:
-
pathTypes
Whether JAR files are modular. This map is redundant withmoduleInfo
, but cheaper to compute when the module names are not needed.- See Also:
-
-
Constructor Details
-
PathModularizationCache
PathModularizationCache()Creates an initially empty cache.
-
-
Method Details
-
getModuleInfo
Gets module information for the given JAR file or output directory. Module descriptors are read when first requested, then cached.- Throws:
IOException
-
getPathType
ReturnsJavaPathType.MODULES
if the given JAR file or output directory is modular. This is used in heuristic rules for deciding whether to place a dependency on the class-path or on the module-path when the"jar"
artifact type is used.- Throws:
IOException
-
selectPathType
Optional<PathType> selectPathType(Set<PathType> types, Predicate<PathType> filter, Path path) throws IOException Selects the type of path where to place the given dependency. This method returns one of the values specified in the given collection. This method does not handle the patch-module paths, because the patches depend on which modules have been previously added on the module-paths.If the dependency can be a constituent of both the class-path and the module-path, then the path type is determined by checking if the dependency is modular.
- Parameters:
types
- types of path where a dependency can be placedfilter
- filter the paths accepted by the tool which will consume the pathpath
- path to the JAR file or output directory of the dependency- Returns:
- where to place the dependency, or an empty value if the placement cannot be determined
- Throws:
IOException
- if an error occurred while reading module information
-
warningForFilenameBasedAutomodules
Optional<String> warningForFilenameBasedAutomodules(Collection<Path> modulePaths) throws IOException If the module-path contains a filename-based auto-module, prepares a warning message. It is caller's responsibility to send the message to a logger.- Parameters:
modulePaths
- content of the module path, ornull
if none- Returns:
- warning message if at least one filename-based auto-module was found
- Throws:
IOException
- if an error occurred while reading module information
-