public final class DirectoryUtils
extends java.lang.Object
RepositorySystemSession.getConfigProperties(),
RepositorySystemSession.getLocalRepository()| Modifier | Constructor and Description |
|---|---|
private |
DirectoryUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.nio.file.Path |
resolveDirectory(RepositorySystemSession session,
java.lang.String defaultName,
java.lang.String nameKey,
boolean mayCreate)
Creates
Path instance out of session configuration, and (if relative) resolve it against local
repository basedir. |
static java.nio.file.Path |
resolveDirectory(java.lang.String name,
java.nio.file.Path base,
boolean mayCreate)
Creates
Path instance out of passed in name parameter. |
public static java.nio.file.Path resolveDirectory(java.lang.String name,
java.nio.file.Path base,
boolean mayCreate)
throws java.io.IOException
Path instance out of passed in name parameter. May create a directory on resulting path,
if not exist, when invoked with mayCreate being true. Never returns null.
Following outcomes may happen:
name is absolute path - results in Path instance created directly from name.name is relative path - results in Path instance resolved against base parameter.
mayCreate is
true. If resulting path exist but is not a directory, this method will throw.name - The name to create directory with, cannot be null.base - The base Path to resolve name, if it is relative path, cannot be null.mayCreate - If resulting path does not exist, should it create?Path instance that is resolved and backed by existing directory.java.io.IOException - If some IO related errors happens.public static java.nio.file.Path resolveDirectory(RepositorySystemSession session, java.lang.String defaultName, java.lang.String nameKey, boolean mayCreate) throws java.io.IOException
Path instance out of session configuration, and (if relative) resolve it against local
repository basedir. Pre-populates values and invokes resolveDirectory(String, Path, boolean).
For this method to work, LocalRepository.getBasedir() must return
non-null value, otherwise NullPointerException is thrown.
session - The session, may not be null.defaultName - The default value if not present in session configuration, may not be null.nameKey - The key to look up for in session configuration to obtain user set value.mayCreate - If resulting path does not exist, should it create?Path instance that is resolved and backed by existing directory.java.io.IOException - If some IO related errors happens.resolveDirectory(String, Path, boolean)