Various file utilities.
Modifiers | Name | Description |
---|---|---|
static java.util.regex.Pattern |
SAFE_FILENAME_REGEX |
Type Params | Return Type | Name and description |
---|---|---|
|
static File |
fileize(Project project, Object file) Converts a file-like object to a File instance with project context. |
|
static java.util.List<File> |
fileize(Project project, Iterable<Object> files) Converts a collection of file-like objects to a a list of File instances with project context. |
|
static FileCollection |
filesFromCopySpec(CopySpec copySpec) Returns the file collection that a CopySpec describes. |
|
static java.util.List<File> |
listDirs(File distDir) Provides a list of directories below another directory |
|
static File |
projectCacheDirFor(Project project) Returns the project cache directory for the given project. |
|
static ClassLocation |
resolveClassLocation(Class aClass) Returns the classpath location for a specific class |
|
static File |
toSafeFile(String... parts) Converts a collection of String into a {@@link File} with all parts guarantee to be safe file parts |
|
static String |
toSafeFileName(String name) Converts a string into a string that is safe to use as a file name. |
|
static java.nio.file.Path |
toSafePath(String... parts) Converts a collection of String into a java.nio.file.Path with all parts guarantee to be safe file parts |
|
static void |
updateFileProperty(Project project, Provider<File> provider, Object file) Updates a Provider. |
Converts a file-like object to a File instance with project context. Converts any of the following recursively until it gets to a file:
CharSequence
including String
and GString
.
file:
schemes.
project
- Project contextConverts a collection of file-like objects to a a list of File instances with project context. It will convert anything that the singular version of fileize(Project project, Object o) can do. In addition it will recursively resolve any collections that result out of resolving the supplied items.
project
- Project contextfiles
- List of object to evaluateReturns the file collection that a CopySpec describes.
copySpec
- An instance of a CopySpecProvides a list of directories below another directory
distDir
- Directorynull
supplied directory.Returns the project cache directory for the given project.
project
- Project to query.null
.Returns the classpath location for a specific class
aClass
- Class to find.null
which means class has been found, but cannot be placed
on classpathConverts a collection of String into a {@
parts
- File path partsConverts a string into a string that is safe to use as a file name. T The result will only include ascii characters and numbers, and the "-","_", #, $ and "." characters.
A
- potential file nameConverts a collection of String into a java.nio.file.Path with all parts guarantee to be safe file parts
parts
- File path partsUpdates a Provider. If the Provider is a Property it will be updated in place, otherwise the provider will be assigned a new Provider instance. This requires Gradle 4.3 at minimum. Alternatively if the Provider is PropertyStore it will also be updated in place.
project
- Project context for creating providersprovider
- Current providerstringy
- Value that should be lazy-resolved.