# file

abstract fun file(path: Any): File

Resolves a file path relative to the project directory of this project. This method converts the supplied path based on its type:

- A CharSequence, including String or groovy.lang.GString. Interpreted relative to the project directory. A string that starts with `file:` is treated as a file URL.
- A File. If the file is an absolute file, it is returned as is. Otherwise, the file's path is interpreted relative to the project directory.
- A java.nio.file.Path. The path must be associated with the default provider and is treated the same way as an instance of `File`.
- A java.net.URI or java.net.URL. The URL's path is interpreted as the file path. Only `file:` URLs are supported.
- A org.gradle.api.file.Directory or org.gradle.api.file.RegularFile.
- A Provider of any supported type. The provider's value is resolved recursively.
- A org.gradle.api.resources.TextResource.
- A Groovy Closure or Kotlin function that returns any supported type. The closure's return value is resolved recursively.
- A java.util.concurrent.Callable that returns any supported type. The callable's return value is resolved recursively.

#### Return

The resolved file. Never returns null.

#### Parameters

path

The object to resolve as a File.

abstract fun file(path: Any, validation: PathValidation): File

Resolves a file path relative to the project directory of this project and validates it using the given scheme. See PathValidation for the list of possible validations.

#### Return

The resolved file. Never returns null.

#### Parameters

path

An object which toString method value is interpreted as a relative path to the project directory.

validation

The validation to perform on the file.

#### Throws

InvalidUserDataException

When the file does not meet the given validation constraint.