# Script

interface Script(source)

This interface is implemented by all Gradle Groovy DSL scripts to add in some Gradle-specific methods. As your compiled script class will implement this interface, you can use the methods and properties declared by this interface directly in your script.

Generally, a `Script` object will have a delegate object attached to it. For example, a build script will have a Project instance attached to it, and an initialization script will have a instance attached to it. Any property reference or method call which is not found on this `Script` object is forwarded to the delegate object.

## Functions

apply
Link copied to clipboard
abstract fun apply(closure: Closure)
abstract fun apply(options: Map<String, out Any>)
Configures the delegate object for this script using plugins or scripts.
apply
Link copied to clipboard
inline fun Script. apply(vararg options: Pair<String, Any?>)

Kotlin extension function for org.gradle.api.Script.apply.

buildscript
Link copied to clipboard
abstract fun buildscript(configureClosure: Closure)
Configures the classpath for this script.
copy
Link copied to clipboard
abstract fun copy(closure: Closure): WorkResult
Copy the specified files.
copySpec
Link copied to clipboard
abstract fun copySpec(closure: Closure): CopySpec
Creates a org.gradle.api.file.CopySpec which can later be used to copy files or create an archive.
delete
Link copied to clipboard
abstract fun delete(paths: Array<Any>): Boolean
Deletes files and directories.
exec
Link copied to clipboard
abstract fun exec(@DelegatesTo(value = ExecSpec::class) closure: Closure): ExecResult
abstract fun exec(action: Action<in ExecSpec>): ExecResult
Executes an external command.
file
Link copied to clipboard
abstract fun file(path: Any): File
Resolves a file path relative to the directory containing this script.
abstract fun file(path: Any, validation: PathValidation): File
Resolves a file path relative to the directory containing this script and validates it using the given scheme.
files
Link copied to clipboard
abstract fun files(paths: Array<Any>): ConfigurableFileCollection
Returns a ConfigurableFileCollection containing the given files.
abstract fun files(paths: Any, configureClosure: Closure): ConfigurableFileCollection
Creates a new `ConfigurableFileCollection` using the given paths.
fileTree
Link copied to clipboard
abstract fun fileTree(baseDir: Any): ConfigurableFileTree
abstract fun fileTree(baseDir: Any, configureClosure: Closure): ConfigurableFileTree
Creates a new `ConfigurableFileTree` using the given base directory.
abstract fun fileTree(args: Map<String, out Any>): ConfigurableFileTree
Creates a new `ConfigurableFileTree` using the provided map of arguments.
fileTree
Link copied to clipboard
inline fun Script. fileTree(vararg args: Pair<String, Any?>): ConfigurableFileTree

Kotlin extension function for org.gradle.api.Script.fileTree.

getBuildscript
Link copied to clipboard
abstract fun getBuildscript(): ScriptHandler
Returns the script handler for this script.
getLogger
Link copied to clipboard
abstract fun getLogger(): Logger
Returns the logger for this script.
getLogging
Link copied to clipboard
abstract fun getLogging(): LoggingManager
Returns the org.gradle.api.logging.LoggingManager which can be used to receive logging and to control the standard output/error capture for this script.
getResources
Link copied to clipboard
abstract fun getResources(): ResourceHandler
Provides access to resource-specific utility methods, for example factory methods that create various resources.
javaexec
Link copied to clipboard
abstract fun javaexec(@DelegatesTo(value = JavaExecSpec::class) closure: Closure): ExecResult
abstract fun javaexec(action: Action<in JavaExecSpec>): ExecResult
Executes a Java main class.
mkdir
Link copied to clipboard
abstract fun mkdir(path: Any): File
Creates a directory and returns a file pointing to it.
provider
Link copied to clipboard
abstract fun <T> provider(value: Callable<T>): Provider<T>
Creates a `Provider` implementation based on the provided value.
relativePath
Link copied to clipboard
abstract fun relativePath(path: Any): String
Returns the relative path from the directory containing this script 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 the directory containing this script.
zipTree
Link copied to clipboard
abstract fun zipTree(zipPath: Any): FileTree
Creates a new `FileTree` which contains the contents of the given ZIP file.