# KotlinScript

interface KotlinScript

Base contract for all Gradle Kotlin DSL scripts.

This is the Kotlin flavored equivalent of org.gradle.api.Script.

It is not implemented directly by the IDE script templates to overcome ambiguous conflicts and Kotlin language limitations.

#### Since

6.0

## Properties

logger
Link copied to clipboard
abstract val logger: Logger

Logger for scripts. You can use this in your script to write log messages.

logging
Link copied to clipboard
abstract val logging: LoggingManager

The LoggingManager which can be used to receive logging and to control the standard output/error capture for this script. By default, `System.out` is redirected to the Gradle logging system at the `QUIET` log level, and `System.err` is redirected at the `ERROR` log level.

resources
Link copied to clipboard
abstract val resources: ResourceHandler

Provides access to resource-specific utility methods, for example factory methods that create various resources.

## Functions

copy
Link copied to clipboard
abstract fun copy(configuration: Action<CopySpec>): WorkResult

Copies the specified files.

copySpec
Link copied to clipboard
abstract fun copySpec(): CopySpec
abstract fun copySpec(configuration: Action<CopySpec>): CopySpec

Creates a {@link CopySpec} which can later be used to copy files or create an archive.

delete
Link copied to clipboard
abstract fun delete(vararg paths: Any): Boolean

Deletes files and directories.

abstract fun delete(configuration: Action<DeleteSpec>): WorkResult

Deletes the specified files.

file
Link copied to clipboard
abstract fun file(path: Any): File
abstract fun file(path: Any, validation: PathValidation): File

Resolves a file path relative to this script's target base directory.

files
Link copied to clipboard
abstract fun files(vararg paths: Any): ConfigurableFileCollection
abstract fun files(paths: Any, configuration: Action<ConfigurableFileCollection>): ConfigurableFileCollection

Creates a ConfigurableFileCollection containing the given files.

fileTree
Link copied to clipboard
abstract fun fileTree(baseDir: Any): ConfigurableFileTree
abstract fun fileTree(baseDir: Any, configuration: Action<ConfigurableFileTree>): ConfigurableFileTree

Creates a new ConfigurableFileTree using the given base directory.

mkdir
Link copied to clipboard
abstract fun mkdir(path: Any): File

Creates a directory and returns a file pointing to it.

relativePath
Link copied to clipboard
abstract fun relativePath(path: Any): String

Returns the relative path from this script's target base directory to the given path.

tarTree
Link copied to clipboard
abstract fun tarTree(tarPath: Any): FileTree

Creates a new FileTree which contains the contents of the given TAR file.

uri
Link copied to clipboard
abstract fun uri(path: Any): URI

Resolves a file path to a URI, relative to this script's target base directory.

zipTree
Link copied to clipboard
abstract fun zipTree(zipPath: Any): FileTree

Creates a new FileTree which contains the contents of the given ZIP file.