Package org.eclipse.aether.util
Class DirectoryUtils
java.lang.Object
org.eclipse.aether.util.DirectoryUtils
A utility class to calculate (and create if needed) paths backed by directories using configuration properties from
repository system session and others.
- Since:
- 1.9.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Path
resolveDirectory
(String name, Path base, boolean mayCreate) CreatesPath
instance out of passed inname
parameter.static Path
resolveDirectory
(org.eclipse.aether.RepositorySystemSession session, String defaultName, String nameKey, boolean mayCreate) CreatesPath
instance out of session configuration, and (if relative) resolve it against local repository basedir.
-
Method Details
-
resolveDirectory
CreatesPath
instance out of passed inname
parameter. May create a directory on resulting path, if not exist, when invoked withmayCreate
beingtrue
. Never returnsnull
.Following outcomes may happen:
name
is absolute path - results inPath
instance created directly from name.name
is relative path - results inPath
instance resolved againstbase
parameter.
mayCreate
istrue
. If resulting path exist but is not a directory, this method will throw.- Parameters:
name
- The name to create directory with, cannot benull
.base
- The basePath
to resolve name, if it is relative path, cannot benull
.mayCreate
- If resulting path does not exist, should it create?- Returns:
- The
Path
instance that is resolved and backed by existing directory. - Throws:
IOException
- If some IO related errors happens.
-
resolveDirectory
public static Path resolveDirectory(org.eclipse.aether.RepositorySystemSession session, String defaultName, String nameKey, boolean mayCreate) throws IOException CreatesPath
instance out of session configuration, and (if relative) resolve it against local repository basedir. Pre-populates values and invokesresolveDirectory(String, Path, boolean)
.For this method to work,
LocalRepository.getBasedir()
must return non-null
value, otherwiseNullPointerException
is thrown.- Parameters:
session
- The session, may not benull
.defaultName
- The default value if not present in session configuration, may not benull
.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?- Returns:
- The
Path
instance that is resolved and backed by existing directory. - Throws:
IOException
- If some IO related errors happens.- See Also:
-